Skip to content

Commit 21da5be

Browse files
benmccannetimberg
authored andcommitted
Fix horizontalBar deprecation warnings (#6603)
Fix horizontalBar deprecation warnings
1 parent ea100d4 commit 21da5be

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/controllers/controller.horizontalBar.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ defaults._set('horizontalBar', {
1818
yAxes: [{
1919
type: 'category',
2020
position: 'left',
21-
categoryPercentage: 0.8,
22-
barPercentage: 0.9,
2321
offset: true,
2422
gridLines: {
2523
offsetGridLines: true
@@ -39,6 +37,15 @@ defaults._set('horizontalBar', {
3937
}
4038
});
4139

40+
defaults._set('global', {
41+
datasets: {
42+
horizontalBar: {
43+
categoryPercentage: 0.8,
44+
barPercentage: 0.9
45+
}
46+
}
47+
});
48+
4249
module.exports = BarController.extend({
4350
/**
4451
* @private
@@ -54,4 +61,3 @@ module.exports = BarController.extend({
5461
return this.getMeta().yAxisID;
5562
}
5663
});
57-

test/specs/controller.bar.tests.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1593,8 +1593,9 @@ describe('Chart.controllers.bar', function() {
15931593
var meta = chart.getDatasetMeta(0);
15941594
var yScale = chart.scales[meta.yAxisID];
15951595

1596-
var categoryPercentage = yScale.options.categoryPercentage;
1597-
var barPercentage = yScale.options.barPercentage;
1596+
var config = meta.controller._config;
1597+
var categoryPercentage = config.categoryPercentage;
1598+
var barPercentage = config.barPercentage;
15981599
var stacked = yScale.options.stacked;
15991600

16001601
var totalBarHeight = 0;

0 commit comments

Comments
 (0)