Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider dynamically positioned scales for padding #8868

Merged
merged 1 commit into from Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/core/core.layouts.js
Expand Up @@ -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};
}
if (layout.size) {
// this layout was already counted for, lets first reduce old size
chartArea[layout.pos] -= layout.size;
// 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;
}
layout.size = layout.horizontal ? box.height : box.width;
chartArea[layout.pos] += layout.size;

if (box.getPadding) {
updateMaxPadding(maxPadding, box.getPadding());
Expand Down
27 changes: 27 additions & 0 deletions test/fixtures/core.scale/x-axis-position-dynamic-margin.js
@@ -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
}
};
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fixtures/core.scale/x-axis-position-dynamic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.