mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
Chart animations will now use the animation service provided in Chart.animationService.
This commit is contained in:
parent
972bc5636d
commit
0b8fd966ff
@ -932,15 +932,27 @@
|
||||
if (reflow){
|
||||
this.reflow();
|
||||
}
|
||||
|
||||
if (this.options.animation && !reflow){
|
||||
helpers.animationLoop(
|
||||
this.draw,
|
||||
this.options.animationSteps,
|
||||
this.options.animationEasing,
|
||||
this.options.onAnimationProgress,
|
||||
this.options.onAnimationComplete,
|
||||
this
|
||||
);
|
||||
var animation = new Chart.Animation();
|
||||
animation.numSteps = this.options.animationSteps;
|
||||
animation.minSteps = 10; // TODO: add an option for this
|
||||
animation.easing = this.options.animationEasing;
|
||||
|
||||
// render function
|
||||
animation.render = function(chartInstance, animationObject) {
|
||||
var easingFunction = helpers.easingEffects[animationObject.easing];
|
||||
var stepDecimal = animationObject.currentStep / animationObject.numSteps;
|
||||
var easeDecimal = easingFunction(stepDecimal);
|
||||
|
||||
chartInstance.draw(chartInstance, easeDecimal, stepDecimal, currentStep);
|
||||
};
|
||||
|
||||
// user events
|
||||
animation.onAnimationProgress = this.options.onAnimationProgress;
|
||||
animation.onAnimationComplete = this.options.onAnimationComplete;
|
||||
|
||||
Chart.animationService.addAnimation(this, animation);
|
||||
}
|
||||
else{
|
||||
this.draw();
|
||||
@ -1347,6 +1359,17 @@
|
||||
}
|
||||
});
|
||||
|
||||
Chart.Animation = Chart.Element.extend({
|
||||
currentStep: null, // the current animation step
|
||||
numSteps: 60, // default number of steps
|
||||
minSteps: 10, // TODO: create an option for this
|
||||
easing: "", // the easing to use for this animation
|
||||
render: null, // render function used by the animation service
|
||||
|
||||
onAnimationProgress: null, // user specified callback to fire on each step of the animation
|
||||
onAnimationComplete: null, // user specified callback to fire when the animation finishes
|
||||
});
|
||||
|
||||
Chart.Tooltip = Chart.Element.extend({
|
||||
draw : function(){
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user