Skip to content

Commit

Permalink
use a variable for _lastValue
Browse files Browse the repository at this point in the history
rather than annotating some random DOM element
  • Loading branch information
gordonwoodhull committed Jul 27, 2016
1 parent 1aa25f3 commit 4dce8ed
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/number-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ dc.numberDisplay = function (parent, chartGroup) {
var _formatNumber = d3.format('.2s');
var _chart = dc.baseMixin({});
var _html = {one: '', some: '', none: ''};
var _lastValue;

// dimension not required
_chart._mandatoryAttributes(['group']);
Expand Down Expand Up @@ -100,9 +101,9 @@ dc.numberDisplay = function (parent, chartGroup) {
.ease('quad-out-in')
.tween('text', function () {
// [XA] don't try and interpolate from Infinity, else this breaks.
var interpStart = isFinite(this.lastValue) ? this.lastValue : 0;
var interpStart = isFinite(_lastValue) ? _lastValue : 0;
var interp = d3.interpolateNumber(interpStart || 0, newValue);
this.lastValue = newValue;
_lastValue = newValue;
return function (t) {
var html = null, num = _chart.formatNumber()(interp(t));
if (newValue === 0 && (_html.none !== '')) {
Expand Down

0 comments on commit 4dce8ed

Please sign in to comment.