]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
When an event triggers an update while the bufferedUpdate state is true, we need...
authoretimberg <evert.timberg@gmail.com>
Sun, 30 Oct 2016 15:03:19 +0000 (11:03 -0400)
committerEvert Timberg <evert.timberg+github@gmail.com>
Sun, 30 Oct 2016 21:58:40 +0000 (16:58 -0500)
src/core/core.animation.js
src/core/core.controller.js

index 7ccb3749322b3ef36ae41aca22efc012eed19aa0..dcb9c2ee0deb67e2ad0083335187fb2d96b00ee7 100644 (file)
@@ -27,6 +27,14 @@ module.exports = function(Chart) {
                animations: [],
                dropFrames: 0,
                request: null,
+
+               /**
+                * @function Chart.animationService.addAnimation
+                * @param chartInstance {ChartController} the chart to animate
+                * @param animationObject {IAnimation} the animation that we will animate
+                * @param duration {Number} length of animation in ms
+                * @param lazy {Boolean} if true, the chart is not marked as animating to enable more responsive interactions
+                */
                addAnimation: function(chartInstance, animationObject, duration, lazy) {
                        var me = this;
 
index e0ad78334d685e3d97f26ceaa4624dd8a3c0e321..0b644c6444a2e8b1268ad21024b5965152903494 100644 (file)
@@ -460,7 +460,12 @@ module.exports = function(Chart) {
                        // Do this before render so that any plugins that need final scale updates can use it
                        Chart.plugins.notify('afterUpdate', [me]);
 
-                       if (!me._bufferedRender) {
+                       if (me._bufferedRender) {
+                               me._bufferedRequest = {
+                                       lazy: lazy,
+                                       duration: animationDuration
+                               };
+                       } else {
                                me.render(animationDuration, lazy);
                        }
                },
@@ -718,12 +723,17 @@ module.exports = function(Chart) {
 
                        // Buffer any update calls so that renders do not occur
                        me._bufferedRender = true;
+                       me._bufferedRequest = null;
 
                        var changed = me.handleEvent(e);
                        changed |= me.legend.handleEvent(e);
                        changed |= me.tooltip.handleEvent(e);
 
-                       if (changed && !me.animating) {
+                       var bufferedRequest = me._bufferedRequest;
+                       if (bufferedRequest) {
+                               // If we have an update that was triggered, we need to do a normal render
+                               me.render(bufferedRequest.duration, bufferedRequest.lazy);
+                       } else if (changed && !me.animating) {
                                // If entering, leaving, or changing elements, animate the change via pivot
                                me.stop();
 
@@ -733,6 +743,8 @@ module.exports = function(Chart) {
                        }
 
                        me._bufferedRender = false;
+                       me._bufferedRequest = null;
+
                        return me;
                },