Chart animations will now use the animation service provided in Chart.animationService.

This commit is contained in:
Evert Timberg 2015-04-11 19:02:50 -04:00
parent 972bc5636d
commit 0b8fd966ff

View File

@ -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(){