Skip to content

Commit 2a03e13

Browse files
authored
Fix backdrop padding (chartjs#11577)
* fix for alignment inner * Add test * Remove eslint ignores * remove unecesarry config * Remove text from test
1 parent 6722512 commit 2a03e13

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

src/core/core.scale.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,6 +1288,13 @@ export default class Scale extends Element {
12881288
case 'right':
12891289
left -= width;
12901290
break;
1291+
case 'inner':
1292+
if (i === ilen - 1) {
1293+
left -= width;
1294+
} else if (i > 0) {
1295+
left -= width / 2;
1296+
}
1297+
break;
12911298
default:
12921299
break;
12931300
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module.exports = {
2+
config: {
3+
type: 'line',
4+
data: {
5+
labels: ['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange'],
6+
datasets: [
7+
{
8+
label: '# of Votes',
9+
data: [12, 19, 3, 5, 2, 3],
10+
},
11+
{
12+
label: '# of Points',
13+
data: [7, 11, 5, 8, 3, 7],
14+
}
15+
]
16+
},
17+
options: {
18+
scales: {
19+
y: {
20+
ticks: {
21+
display: false,
22+
},
23+
grid: {
24+
lineWidth: 0
25+
}
26+
},
27+
x: {
28+
position: 'top',
29+
ticks: {
30+
color: 'transparent',
31+
backdropColor: 'red',
32+
showLabelBackdrop: true,
33+
align: 'inner',
34+
},
35+
grid: {
36+
lineWidth: 0
37+
}
38+
}
39+
}
40+
}
41+
},
42+
options: {
43+
canvas: {
44+
height: 256,
45+
width: 512
46+
}
47+
}
48+
};
10.9 KB
Loading

0 commit comments

Comments
 (0)