Skip to content

Commit

Permalink
Fix backdrop padding (#11577)
Browse files Browse the repository at this point in the history
* fix for alignment inner

* Add test

* Remove eslint ignores

* remove unecesarry config

* Remove text from test
  • Loading branch information
LeeLenaleee authored Nov 9, 2023
1 parent 6722512 commit 2a03e13
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,13 @@ export default class Scale extends Element {
case 'right':
left -= width;
break;
case 'inner':
if (i === ilen - 1) {
left -= width;
} else if (i > 0) {
left -= width / 2;
}
break;
default:
break;
}
Expand Down
48 changes: 48 additions & 0 deletions test/fixtures/core.scale/tick-backdrop-alignment-inner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module.exports = {
config: {
type: 'line',
data: {
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
datasets: [
{
label: '# of Votes',
data: [12, 19, 3, 5, 2, 3],
},
{
label: '# of Points',
data: [7, 11, 5, 8, 3, 7],
}
]
},
options: {
scales: {
y: {
ticks: {
display: false,
},
grid: {
lineWidth: 0
}
},
x: {
position: 'top',
ticks: {
color: 'transparent',
backdropColor: 'red',
showLabelBackdrop: true,
align: 'inner',
},
grid: {
lineWidth: 0
}
}
}
}
},
options: {
canvas: {
height: 256,
width: 512
}
}
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 2a03e13

Please sign in to comment.