mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 20:29:12 +02:00
Bar dataset controller needs a better way to know which datasets are bars since users could make their own bar types.
This commit is contained in:
parent
3ccf3fd249
commit
8efa577ef5
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user