From 195cace7c215ec90ae29d2a90ac439ba5c2595f8 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 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 { -- 2.47.3