From 21da5be3c63e69a4edfc364d040e270471d8234d Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sat, 26 Oct 2019 09:48:48 -0700 Subject: [PATCH] Fix horizontalBar deprecation warnings (#6603) Fix horizontalBar deprecation warnings --- src/controllers/controller.horizontalBar.js | 12 +++++++++--- test/specs/controller.bar.tests.js | 5 +++-- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/controllers/controller.horizontalBar.js b/src/controllers/controller.horizontalBar.js index ebfc6d84ae1..7b11bcc6627 100644 --- a/src/controllers/controller.horizontalBar.js +++ b/src/controllers/controller.horizontalBar.js @@ -18,8 +18,6 @@ defaults._set('horizontalBar', { yAxes: [{ type: 'category', position: 'left', - categoryPercentage: 0.8, - barPercentage: 0.9, offset: true, gridLines: { offsetGridLines: true @@ -39,6 +37,15 @@ defaults._set('horizontalBar', { } }); +defaults._set('global', { + datasets: { + horizontalBar: { + categoryPercentage: 0.8, + barPercentage: 0.9 + } + } +}); + module.exports = BarController.extend({ /** * @private @@ -54,4 +61,3 @@ module.exports = BarController.extend({ return this.getMeta().yAxisID; } }); - diff --git a/test/specs/controller.bar.tests.js b/test/specs/controller.bar.tests.js index 3874c3325df..e52c9340fc1 100644 --- a/test/specs/controller.bar.tests.js +++ b/test/specs/controller.bar.tests.js @@ -1593,8 +1593,9 @@ describe('Chart.controllers.bar', function() { var meta = chart.getDatasetMeta(0); var yScale = chart.scales[meta.yAxisID]; - var categoryPercentage = yScale.options.categoryPercentage; - var barPercentage = yScale.options.barPercentage; + var config = meta.controller._config; + var categoryPercentage = config.categoryPercentage; + var barPercentage = config.barPercentage; var stacked = yScale.options.stacked; var totalBarHeight = 0;