From 6b32466a1970d013a1aa6a422fb076586218fec5 Mon Sep 17 00:00:00 2001 From: Lighnat0r Date: Wed, 27 Apr 2016 21:26:20 +0200 Subject: [PATCH] update time scale range only for visible datasets --- src/scales/scale.time.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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 {