From: Jukka Kurkela Date: Sun, 21 Feb 2021 20:43:31 +0000 (+0200) Subject: Only consider visible vertical boxes in layout (#8483) X-Git-Tag: v3.0.0-beta.12~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6f0e7959dff7f2b50809fcbecf6dd5d670b7982b;p=thirdparty%2FChart.js.git Only consider visible vertical boxes in layout (#8483) --- diff --git a/src/core/core.layouts.js b/src/core/core.layouts.js index 30661a17f..acb1b4ce2 100644 --- a/src/core/core.layouts.js +++ b/src/core/core.layouts.js @@ -343,13 +343,16 @@ export default { // |----------------------------------------------------| // + const visibleVerticalBoxCount = verticalBoxes.reduce((total, wrap) => + wrap.box.options && wrap.box.options.display === false ? total : total + 1, 0); + const params = Object.freeze({ outerWidth: width, outerHeight: height, padding, availableWidth, availableHeight, - vBoxMaxWidth: availableWidth / 2 / verticalBoxes.length, + vBoxMaxWidth: availableWidth / 2 / visibleVerticalBoxCount, hBoxMaxHeight: availableHeight / 2 }); const chartArea = Object.assign({ diff --git a/test/fixtures/core.layouts/hidden-vertical-boxes.js b/test/fixtures/core.layouts/hidden-vertical-boxes.js new file mode 100644 index 000000000..5b55600bb --- /dev/null +++ b/test/fixtures/core.layouts/hidden-vertical-boxes.js @@ -0,0 +1,62 @@ +module.exports = { + config: { + type: 'line', + data: { + datasets: [ + {data: [10, 5, 0, 25, 78, -10]} + ], + labels: ['tick1', 'tick2', 'tick3', 'tick4', 'tick5', ''] + }, + options: { + plugins: { + legend: false + }, + scales: { + x: { + display: false + }, + y: { + type: 'linear', + position: 'left', + ticks: { + callback: function(value) { + return value + ' very long unit!'; + }, + } + }, + y1: { + type: 'linear', + position: 'left', + display: false + }, + y2: { + type: 'linear', + position: 'left', + display: false + }, + y3: { + type: 'linear', + position: 'left', + display: false + }, + y4: { + type: 'linear', + position: 'left', + display: false + }, + y5: { + type: 'linear', + position: 'left', + display: false + } + } + } + }, + options: { + spriteText: true, + canvas: { + height: 256, + width: 256 + } + } +}; diff --git a/test/fixtures/core.layouts/hidden-vertical-boxes.png b/test/fixtures/core.layouts/hidden-vertical-boxes.png new file mode 100644 index 000000000..5746067d3 Binary files /dev/null and b/test/fixtures/core.layouts/hidden-vertical-boxes.png differ diff --git a/test/fixtures/plugin.legend/title/left-center-center.png b/test/fixtures/plugin.legend/title/left-center-center.png index cbcdb6593..7ffd40094 100644 Binary files a/test/fixtures/plugin.legend/title/left-center-center.png and b/test/fixtures/plugin.legend/title/left-center-center.png differ diff --git a/test/fixtures/plugin.legend/title/left-end-end.png b/test/fixtures/plugin.legend/title/left-end-end.png index 85c33c674..a60610ab5 100644 Binary files a/test/fixtures/plugin.legend/title/left-end-end.png and b/test/fixtures/plugin.legend/title/left-end-end.png differ diff --git a/test/fixtures/plugin.legend/title/right-center-center.png b/test/fixtures/plugin.legend/title/right-center-center.png index 794aea86c..9900784a4 100644 Binary files a/test/fixtures/plugin.legend/title/right-center-center.png and b/test/fixtures/plugin.legend/title/right-center-center.png differ diff --git a/test/fixtures/plugin.legend/title/right-end-end.png b/test/fixtures/plugin.legend/title/right-end-end.png index 97a0c8489..ec2acbf13 100644 Binary files a/test/fixtures/plugin.legend/title/right-end-end.png and b/test/fixtures/plugin.legend/title/right-end-end.png differ diff --git a/test/fixtures/plugin.legend/title/right-start-start.png b/test/fixtures/plugin.legend/title/right-start-start.png index bd49b4b80..89c5286ef 100644 Binary files a/test/fixtures/plugin.legend/title/right-start-start.png and b/test/fixtures/plugin.legend/title/right-start-start.png differ