mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 12:19:08 +02:00
Consider dynamically positioned scales for padding (#8868)
This commit is contained in:
parent
ba84cc5c2a
commit
1ffdecfe68
@ -93,16 +93,15 @@ function updateDims(chartArea, params, layout) {
|
||||
const box = layout.box;
|
||||
const maxPadding = chartArea.maxPadding;
|
||||
|
||||
if (isObject(layout.pos)) {
|
||||
// dynamically placed boxes are not considered
|
||||
return {same: false, other: false};
|
||||
// dynamically placed boxes size is not considered
|
||||
if (!isObject(layout.pos)) {
|
||||
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) {
|
||||
updateMaxPadding(maxPadding, box.getPadding());
|
||||
|
27
test/fixtures/core.scale/x-axis-position-dynamic-margin.js
vendored
Normal file
27
test/fixtures/core.scale/x-axis-position-dynamic-margin.js
vendored
Normal 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
|
||||
}
|
||||
};
|
BIN
test/fixtures/core.scale/x-axis-position-dynamic-margin.png
vendored
Normal file
BIN
test/fixtures/core.scale/x-axis-position-dynamic-margin.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.7 KiB |
BIN
test/fixtures/core.scale/x-axis-position-dynamic.png
vendored
BIN
test/fixtures/core.scale/x-axis-position-dynamic.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Loading…
Reference in New Issue
Block a user