From: Lighnat0r Date: Wed, 27 Apr 2016 19:26:20 +0000 (+0200) Subject: update time scale range only for visible datasets X-Git-Tag: 2.1.0~24^2~1^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=195cace7c215ec90ae29d2a90ac439ba5c2595f8;p=thirdparty%2FChart.js.git update time scale range only for visible datasets --- diff --git a/src/scales/scale.time.js b/src/scales/scale.time.js index 45ce64b43..f8064a8e3 100644 --- a/src/scales/scale.time.js +++ b/src/scales/scale.time.js @@ -104,6 +104,7 @@ module.exports = function(Chart) { helpers.each(this.chart.data.datasets, function(dataset, datasetIndex) { var momentsForDataset = []; + var datasetVisible = helpers.isDatasetVisible(dataset); if (typeof dataset.data[0] === 'object') { helpers.each(dataset.data, function(value, index) { @@ -115,9 +116,11 @@ module.exports = function(Chart) { } momentsForDataset.push(labelMoment); - // May have gone outside the scale ranges, make sure we keep the first and last ticks updated - this.firstTick = this.firstTick !== null ? moment.min(this.firstTick, labelMoment) : labelMoment; - this.lastTick = this.lastTick !== null ? moment.max(this.lastTick, labelMoment) : labelMoment; + if (datasetVisible) { + // May have gone outside the scale ranges, make sure we keep the first and last ticks updated + this.firstTick = this.firstTick !== null ? moment.min(this.firstTick, labelMoment) : labelMoment; + this.lastTick = this.lastTick !== null ? moment.max(this.lastTick, labelMoment) : labelMoment; + } } }, this); } else {