From 795fb841f3846a973c1de99c3921a51f30f2aeb6 Mon Sep 17 00:00:00 2001 From: Jukka Kurkela Date: Tue, 23 Feb 2021 19:19:35 +0200 Subject: [PATCH] Fix layout bug when there are no visible boxes --- src/core/core.layouts.js | 2 +- .../core.layouts/no-boxes-all-padding.js | 39 ++++++++++++++++++ .../core.layouts/no-boxes-all-padding.png | Bin 0 -> 709 bytes 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/core.layouts/no-boxes-all-padding.js create mode 100644 test/fixtures/core.layouts/no-boxes-all-padding.png diff --git a/src/core/core.layouts.js b/src/core/core.layouts.js index acb1b4ce2ec..7868eb67621 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 00000000000..ae8500851be --- /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 0000000000000000000000000000000000000000..6bade811f6d75d98a1af9dfb2972314406220838 GIT binary patch literal 709 zcmV;$0y_PPP)qf90%~vq)404qGIjXmsk=9AtZ!G8kKNzsNffVZjU z`T=NQ?ILbWrX)w-ebhVo{F=&DG$e2I0T52UgBPX4>^$KxfVjre?vT4}_F1Sfg{#5g~b1G&C=I`DxLZPYB}XpoHq2%)xyrfk`s&S~m?h>j;L3n3Z+ z6vVhZm#Rz+zkPQKK!WN-J>6kq+? z@~5nw!_DCa5uCqa%gUkJ@&u}I6P4VV&azxN5#IbgO?TOxeDXnWAh8iR@sndyIFfC2 z1h#ilGlnx6jb_Qr3LWzTPLxs=2Gjo?PCK|7<7C#uX$rjy&M|ExL%KsbYb!j-oCKo%@b7=00000NkvXXu0mjf^5scP literal 0 HcmV?d00001