Consider dynamically positioned scales for padding (#8868)

This commit is contained in:
Jukka Kurkela 2021-04-10 15:58:39 +03:00 committed by GitHub
parent ba84cc5c2a
commit 1ffdecfe68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 9 deletions

View File

@ -93,16 +93,15 @@ function updateDims(chartArea, params, layout) {
const box = layout.box; const box = layout.box;
const maxPadding = chartArea.maxPadding; const maxPadding = chartArea.maxPadding;
if (isObject(layout.pos)) { // dynamically placed boxes size is not considered
// dynamically placed boxes are not considered if (!isObject(layout.pos)) {
return {same: false, other: false}; if (layout.size) {
// this layout was already counted for, lets first reduce old size
chartArea[layout.pos] -= layout.size;
}
layout.size = layout.horizontal ? box.height : box.width;
chartArea[layout.pos] += layout.size;
} }
if (layout.size) {
// this layout was already counted for, lets first reduce old size
chartArea[layout.pos] -= layout.size;
}
layout.size = layout.horizontal ? box.height : box.width;
chartArea[layout.pos] += layout.size;
if (box.getPadding) { if (box.getPadding) {
updateMaxPadding(maxPadding, box.getPadding()); updateMaxPadding(maxPadding, box.getPadding());

View File

@ -0,0 +1,27 @@
module.exports = {
config: {
type: 'line',
options: {
scales: {
x: {
labels: ['Left Label', 'Center Label', 'Right Label'],
position: {
y: 30
},
},
y: {
display: false,
min: -100,
max: 100,
}
}
}
},
options: {
canvas: {
height: 256,
width: 512
},
spriteText: true
}
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB