]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
update time scale range only for visible datasets
authorLighnat0r <Lighnat0r@users.noreply.github.com>
Wed, 27 Apr 2016 19:26:20 +0000 (21:26 +0200)
committerLighnat0r <Lighnat0r@users.noreply.github.com>
Wed, 27 Apr 2016 19:26:20 +0000 (21:26 +0200)
src/scales/scale.time.js

index 45ce64b43d707d06b1db135b421feb578aaa4d96..f8064a8e3d25a70ee899a4bfe44c537268f5d3d2 100644 (file)
@@ -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 {