gRaphael Pie Chart : Add animation

2020-03-30 01:39发布

问题:

I want to display the pie chart with an animation that will make it grow from a "small point" to full size pie chart , something like this growing pie or this Highcharts Demo Gallery - Pie , but I want to apply it to a pie made with gRaphael ,

Here's my jsfiddle example... raphael pie chart with legend

Thanks ahead,

回答1:

In order to achieve that kind of animation you have to access the sectors and... animate them :)

You can do this using your_pie.each()

pie.each(function(){
  //scale each sector to 0
  this.sector.scale(0, 0, this.cx, this.cy);
  //animate from 0 to default size
  this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 1000, "bounce");
});

The fiddle is here: http://jsfiddle.net/85VtZ/6/

Have fun ;)