From 8efa577ef518e6649c2eed31c445b9d31e6cc5e6 Mon Sep 17 00:00:00 2001 From: etimberg Date: Tue, 15 Dec 2015 20:13:37 -0500 Subject: [PATCH] Bar dataset controller needs a better way to know which datasets are bars since users could make their own bar types. --- src/controllers/controller.bar.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/controllers/controller.bar.js b/src/controllers/controller.bar.js index c1c667d33..da09ddf3f 100644 --- a/src/controllers/controller.bar.js +++ b/src/controllers/controller.bar.js @@ -31,16 +31,18 @@ }; 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; -- 2.47.3