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~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6b32466a1970d013a1aa6a422fb076586218fec5;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 620eac88c..af5bb8922 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 {