Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What if I want to animate the LineChartView progression? #85

Closed
kidsid49 opened this issue Aug 8, 2014 · 3 comments
Closed

What if I want to animate the LineChartView progression? #85

kidsid49 opened this issue Aug 8, 2014 · 3 comments

Comments

@kidsid49
Copy link

kidsid49 commented Aug 8, 2014

I wants to animate the LineChartView progression.
Eg. The stroke end of CAShapeLayer that is involved.

I did it by doing it in drawRect of JBLineChartView.m

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"];
    animation.fromValue = @0;
    animation.toValue = @1;
    animation.duration = 2.0;
    animation.delegate=self;
    [shapeLayer addAnimation:animation forKey:@"JBLineStroke"];

Is it ok do animation in DrawRect?
And How to synch it with dot animation if dots does scales up animation only when line reaches to that particular point?

@terryworona
Copy link
Collaborator

Hey @kidsid49, this particular feature has been requested quite a few times.

Unfortunately, we don't plan on supported it going forward.

I can't speak to how you would animate it, but core animation is a good start.

I wouldn't put it into drawRect, but instead tie it into the setState flow, passing the state and callback all the way down to the linesView subview (where the animation can take place).

@sbauch
Copy link

sbauch commented Dec 18, 2014

I achieved this by just putting a "cover" UIView on top of the chart and animating its frame in order to reveal the line beneath it. Hacky but works!

@terryworona
Copy link
Collaborator

@kidsid49 you should animate in the setState: function - it definitely shouldn't be done in drawRect since that can (and will) be called any number of times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants