hyousuf
Posts: 4
Joined: Thu Mar 24, 2011 5:36 pm

Animation

Is there any call back function available for Animation in HighCharts?

because currently the load event for highchart is only for rendering, the animation happens after the load event is fired
hfrntt
Posts: 6393
Joined: Mon Aug 30, 2010 8:41 am
Contact: Website

Re: Animation

Unfortunately for now there's no way to trigger a function after animation.
Slawek Kolodziej
Highcharts support team
torstein.honsi
Site Admin
Posts: 9215
Joined: Thu Nov 09, 2006 11:22 am
Location: Vik i Sogn, Norway

Re: Animation

Hey, wait a minute...

Actually there is. See http://jsfiddle.net/U2BnR/
Torstein Hønsi
CTO, Founder
Highsoft
gynoola
Posts: 1
Joined: Thu May 19, 2011 10:11 am

Re: Animation

Animation companies that offer work placements to uni students? I am a computer animation student looking for somewhere to do some work experence. Anyone know of anywhere that offers work placements to students?
_________________________
external keyword tool ~ keyworddiscovery.com ~ keycompete.com ~ compete.com ~ webmasterworld.com
Last edited by gynoola on Wed May 25, 2011 7:17 am, edited 1 time in total.
hfrntt
Posts: 6393
Joined: Mon Aug 30, 2010 8:41 am
Contact: Website

Re: Animation

Does your question have anything to do with highcharts?
Slawek Kolodziej
Highcharts support team
mkr
Posts: 19
Joined: Tue Aug 06, 2013 9:15 am

Re: Animation

torstein.honsi wrote:Hey, wait a minute...

Actually there is. See http://jsfiddle.net/U2BnR/
Hi,
this is only for inital rendering right?
Is there an event that fires each time AFTER series animation has finished?

Greetz
seba
Posts: 4415
Joined: Tue Jul 31, 2012 2:26 pm

Re: Animation

Animation is called on each redraw, so when you need to catch it? which scenario?
Sebastian Bochan
Highcharts Developer
mkr
Posts: 19
Joined: Tue Aug 06, 2013 9:15 am

Re: Animation

seba wrote:Animation is called on each redraw, so when you need to catch it? which scenario?
Hi,
I have custom labels next to each series in my chart (using the highcharts renderer). Hiding one of the series changes the yAxis and the labels` positions are then incorrect. I cant use the redraw event because at the time it fires, the axis "toPixel()" function still delivers the old value (which I use to position my labels). Using setTimeout I can achieve want I want, but I don´t want to use it.

When I tested the animation -> complete event, it only fired initially.

Thx for the help
Fusher
Posts: 7912
Joined: Mon Jan 30, 2012 10:16 am

Re: Animation

If you could create simple jsFiddle demo, we would check out this. Anyway, can't you simply use labelFormatter? Like here: http://api.highcharts.com/highcharts#le ... lFormatter

Or if you need to live update that values, use this plugin: http://www.highcharts.com/plugin-regist ... -In-Legend
Paweł Fus
Highcharts Developer
mkr
Posts: 19
Joined: Tue Aug 06, 2013 9:15 am

Re: Animation

Thanks Fusher, but i have moving labels that change position everytime the extremes, the chart data or chart visibility change, so I can´t use the label formatter.
What I need is a callback like the animation complete callback everytime a chart animation has finished.
In the following example you can see that the callback only fires once.

http://jsfiddle.net/J24DL/
Fusher
Posts: 7912
Joined: Mon Jan 30, 2012 10:16 am

Re: Animation

You can set animation in three places:

- in chart.animation - it will set default animation for all except initiall animation for series
- in series.animation - it will set only first rendering animation
- in each method as param - it will use that animation instead of chart.animation

See all of them in action here: http://jsfiddle.net/C2pE9/

Note: animation is called for each object which is animated.
Paweł Fus
Highcharts Developer
al-jabr
Posts: 4
Joined: Wed Jun 25, 2014 9:09 pm

Re: Animation

I can't seem to get the animation callback to work for my scenario. I would like to update my series from unstacked line to stacked area with a button, and I would like the series to animate to their new positions. I can do this with setTimeout but I would really like to use an animation callback. The problem is if I do chart.redraw({complete: callbackFun}), the series update immediately without transition. Is there a way to set an animation callback that only fires after the entire animation is complete?

I want behavior like this: http://jsfiddle.net/KVpzk/

Alternatively, if there's a way to do this animation without a complicated callback, I'd love to know how. I haven't been able to find anything so far.
Fusher
Posts: 7912
Joined: Mon Jan 30, 2012 10:16 am

Re: Animation

So that solution should resolve your issue: http://jsfiddle.net/KVpzk/1/

The problem is that redraw() according to docs doesn't have animate param (but it has in the fact). But this redraw works a slightly different - is set animations for a chart, not for actual redraw.
Paweł Fus
Highcharts Developer
al-jabr
Posts: 4
Joined: Wed Jun 25, 2014 9:09 pm

Re: Animation

Thanks, this works great.

A couple pitfalls to avoid:
-calling chart.redraw() after chart.redraw({complete: callbackFun}) messes up the callback
-in some cases I had to set series[0].isDirty = true before chart.redraw({complete: callbackFun}) to get the chart to actually redraw
Fusher
Posts: 7912
Joined: Mon Jan 30, 2012 10:16 am

Re: Animation

isDirty shouldn't be reqiured, but indeed, it may be helpful.
Paweł Fus
Highcharts Developer

Return to “Highcharts Usage”