最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Highcharts loading animation after setdata - Stack Overflow

programmeradmin1浏览0评论

I am using Highcharts graphs and I am using .setData to update the data in the graph.

This is all working fine but I would like to use the loading animation (where the line chart draws itself from left to right) to be triggered every time I reset the data. Is there a way to call this animation?

I am using Highcharts graphs and I am using .setData to update the data in the graph.

This is all working fine but I would like to use the loading animation (where the line chart draws itself from left to right) to be triggered every time I reset the data. Is there a way to call this animation?

Share Improve this question edited Sep 12, 2013 at 16:08 nilskp 3,1272 gold badges31 silver badges34 bronze badges asked Apr 13, 2013 at 11:28 user1766412user1766412 1211 gold badge1 silver badge5 bronze badges 1
  • by default, it should animate i think.. api.highcharts.com/highcharts#chart.animation, can you post a fiddle? – asifrc Commented Apr 13, 2013 at 12:12
Add a comment  | 

3 Answers 3

Reset to default 10

You can remove actual series, and add new one. Initial animation is different from all others (clip path is animated, not series itself).

See example: http://jsfiddle.net/UTC6e/2/

    chart.series[0].remove();
    chart.addSeries({data:[229.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4]} );

In the api reference I see the method setVisible(): "A utility function to show or hide the series with an optional redraw.". I think that's what you're looking for?

UPDATE: added JS Fiddle, see: http://jsfiddle.net/UTC6e/1/

So you could first setVisible to false, then set the new data, and at the end setVisible to true and tell the chart to redraw (second boolean argument).

chart.series[0].setVisible(false);
chart.series[0].setData([229.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4, 29.9, 71.5, 106.4] );
chart.series[0].setVisible(true, true);

You could just manually call the redraw method:

chart.redraw();
发布评论

评论列表(0)

  1. 暂无评论