]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Bar dataset controller needs a better way to know which datasets are bars since users...
authoretimberg <evert.timberg@gmail.com>
Wed, 16 Dec 2015 01:13:37 +0000 (20:13 -0500)
committeretimberg <evert.timberg@gmail.com>
Wed, 16 Dec 2015 01:13:37 +0000 (20:13 -0500)
src/controllers/controller.bar.js

index c1c667d334e9a9a46284c6a89d2bde4913e55071..da09ddf3f47eeb81d391229796a13129c32f0a52 100644 (file)
        };
 
        Chart.controllers.bar = Chart.DatasetController.extend({
+               initialize: function(chart, datasetIndex) {
+                       Chart.DatasetController.prototype.initialize.call(this, chart, datasetIndex);
+
+                       // Use this to indicate that this is a bar dataset. 
+                       this.getDataset().bar = true;
+               },
                // Get the number of datasets that display bars. We use this to correctly calculate the bar width
                getBarCount: function getBarCount() {
                        var barCount = 0;
                        helpers.each(this.chart.data.datasets, function(dataset) {
-                               if (helpers.isDatasetVisible(dataset)) {
-                                       if (dataset.type === 'bar') {
-                                               ++barCount;
-                                       } else if (dataset.type === undefined && this.chart.config.type === 'bar') {
-                                               ++barCount;
-                                       }
+                               if (helpers.isDatasetVisible(dataset) && dataset.bar) {
+                                       ++barCount;
                                }
                        }, this);
                        return barCount;