From: Jukka Kurkela Date: Wed, 24 Feb 2021 21:27:11 +0000 (+0200) Subject: Fix layout bug when there are no visible boxes (#8507) X-Git-Tag: v3.0.0-beta.12~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ab5552acb259b0c980c1a47d7e3820682cf0ff2;p=thirdparty%2FChart.js.git Fix layout bug when there are no visible boxes (#8507) --- diff --git a/src/core/core.layouts.js b/src/core/core.layouts.js index acb1b4ce2..7868eb676 100644 --- a/src/core/core.layouts.js +++ b/src/core/core.layouts.js @@ -344,7 +344,7 @@ export default { // const visibleVerticalBoxCount = verticalBoxes.reduce((total, wrap) => - wrap.box.options && wrap.box.options.display === false ? total : total + 1, 0); + wrap.box.options && wrap.box.options.display === false ? total : total + 1, 0) || 1; const params = Object.freeze({ outerWidth: width, diff --git a/test/fixtures/core.layouts/no-boxes-all-padding.js b/test/fixtures/core.layouts/no-boxes-all-padding.js new file mode 100644 index 000000000..ae8500851 --- /dev/null +++ b/test/fixtures/core.layouts/no-boxes-all-padding.js @@ -0,0 +1,39 @@ +module.exports = { + config: { + type: 'line', + data: { + labels: [0], + datasets: [{ + data: [0], + radius: 16, + backgroundColor: 'red' + }], + }, + options: { + plugins: { + legend: false, + tooltip: false, + title: false, + filler: false + }, + scales: { + x: { + display: false, + offset: true + }, + y: { + display: false + } + }, + layout: { + padding: 16 + } + } + }, + options: { + canvas: { + height: 32, + width: 32 + } + } +}; diff --git a/test/fixtures/core.layouts/no-boxes-all-padding.png b/test/fixtures/core.layouts/no-boxes-all-padding.png new file mode 100644 index 000000000..6bade811f Binary files /dev/null and b/test/fixtures/core.layouts/no-boxes-all-padding.png differ