]> 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@gmail.com>
Wed, 27 Apr 2016 20:46:49 +0000 (22:46 +0200)
src/scales/scale.time.js

index 620eac88c0a9d263221be42525479e6219261aae..af5bb892277da91d19fecd6b00613fd424475432 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 {