]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Animation on refresh
authorEvert Timberg <evert.timberg@gmail.com>
Tue, 2 Jun 2015 22:54:18 +0000 (18:54 -0400)
committerEvert Timberg <evert.timberg@gmail.com>
Tue, 2 Jun 2015 22:54:18 +0000 (18:54 -0400)
src/Chart.Core.js

index a38ffdc44d32a3445912150abc49df67ef207b85..8b7886f8719b25c4d26b47c422f0b049df4cf95c 100755 (executable)
         initialize: function() {},
         pivot: function() {
             if (!this._view) {
-                this._view = clone(this._model);
+                this._view = {};
             }
             this._start = clone(this._view);
             return this;
         },
         transition: function(ease) {
             if (!this._view) {
-                this._view = clone(this._model);
+                this._view = {};
             }
             if (!this._start) {
                 this.pivot();
 
                 // Init if doesn't exist
                 else if (!this._view[key]) {
-                    this._view[key] = value || null;
+                    if (typeof value === 'number') {
+                        this._view[key] = value * ease;
+                    } else {
+                        this._view[key] = value || null;
+                    }
                 }
 
                 // No unnecessary computations
                 }
                 // Number transitions
                 else if (typeof value === 'number') {
-                    this._view[key] = ((this._model[key] - this._start[key]) * ease) + this._start[key];
+                    var startVal = this._start[key] !== undefined ? this._start[key] : 0;
+                    this._view[key] = ((this._model[key] - startVal) * ease) + startVal;
                 }
                 // Everything else
                 else {