From: Evert Timberg Date: Tue, 2 Jun 2015 22:54:18 +0000 (-0400) Subject: Animation on refresh X-Git-Tag: v2.0-alpha~2^2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b2d2efc7ada2fd66d1779509eb7a6a1f5763b92;p=thirdparty%2FChart.js.git Animation on refresh --- diff --git a/src/Chart.Core.js b/src/Chart.Core.js index a38ffdc44..8b7886f87 100755 --- a/src/Chart.Core.js +++ b/src/Chart.Core.js @@ -1131,14 +1131,14 @@ 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(); @@ -1152,7 +1152,11 @@ // 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 @@ -1171,7 +1175,8 @@ } // 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 {