From a4e8f44a6dd28c7d3ec993bec640130696afbb32 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Fri, 25 Oct 2019 18:42:43 -0700 Subject: [PATCH 1/2] Fix horizontalBar deprecation warnings --- src/controllers/controller.horizontalBar.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 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; } }); - From f34100fca3c16ce65b1aad9a5b960aa12f1fd870 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Sat, 26 Oct 2019 09:19:06 -0700 Subject: [PATCH 2/2] Fix tests --- test/specs/controller.bar.tests.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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;