]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
buildOrUpdateControllers now returns an array of all the new controllers that were... 1929/head
authorEvert Timberg <evert.timberg@gmail.com>
Fri, 22 Jan 2016 03:00:21 +0000 (22:00 -0500)
committerEvert Timberg <evert.timberg@gmail.com>
Fri, 22 Jan 2016 03:00:21 +0000 (22:00 -0500)
src/core/core.controller.js

index 654964c0b05924840aa951db586358bd2a4649a2..b0e1b08f7a185ce77d9c784229b59c2ab4adf9bf 100644 (file)
                        Chart.layoutService.update(this, this.chart.width, this.chart.height);
                },
 
-               buildOrUpdateControllers: function buildOrUpdateControllers(resetNewControllers) {
+               buildOrUpdateControllers: function buildOrUpdateControllers() {
                        var types = [];
+                       var newControllers = [];
+
                        helpers.each(this.data.datasets, function(dataset, datasetIndex) {
                                if (!dataset.type) {
                                        dataset.type = this.config.type;
                                        dataset.controller.updateIndex(datasetIndex);
                                } else {
                                        dataset.controller = new Chart.controllers[type](this, datasetIndex);
-
-                                       if (resetNewControllers) {
-                                               dataset.controller.reset();
-                                       }
+                                       newControllers.push(dataset.controller);
                                }
                        }, this);
 
                                        }
                                }
                        }
+
+                       return newControllers;
                },
 
                resetElements: function resetElements() {
                        this.tooltip._data = this.data;
 
                        // Make sure dataset controllers are updated and new controllers are reset
-                       this.buildOrUpdateControllers(true);
+                       var newControllers = this.buildOrUpdateControllers();
 
                        Chart.layoutService.update(this, this.chart.width, this.chart.height);
 
+                       // Can only reset the new controllers after the scales have been updated
+                       helpers.each(newControllers, function(controller) {
+                               controller.reset();
+                       });
+
                        // Make sure all dataset controllers have correct meta data counts
                        helpers.each(this.data.datasets, function(dataset, datasetIndex) {
                                dataset.controller.buildOrUpdateElements();