Skip to content

Commit d68bbe2

Browse files
committed
fix: fix
1 parent a49bfb7 commit d68bbe2

11 files changed

+13
-38
lines changed
Loading
-6 Bytes
Loading
39 Bytes
Loading
-4 Bytes
Loading
21 Bytes
Loading
55 Bytes
Loading
Loading
Loading
Loading

src/core/shapes/bar-x/prepare-data.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,20 @@ async function getLabelData(
6363
} else {
6464
const getTextSize = getTextSizeFn({style});
6565
const {width, height, hangingOffset} = await getTextSize(text);
66-
let y = Math.max(height, d.y - d.series.dataLabels.padding);
66+
let y = Math.max(height, d.y - height + hangingOffset - d.series.dataLabels.padding);
6767
if (d.series.dataLabels.inside) {
68-
y = d.y + d.height / 2;
68+
const centerY = d.y + d.height / 2;
69+
y = Math.min(
70+
d.y + d.height - height + hangingOffset,
71+
centerY - height / 2 + hangingOffset,
72+
);
6973
}
7074
const centerX = Math.min(xMax - width / 2, Math.max(width / 2, d.x + d.width / 2));
7175
return {
7276
svgLabel: {
7377
text,
7478
x: centerX,
75-
y: y - height / 2 + hangingOffset,
79+
y,
7680
style,
7781
size: {width, height, hangingOffset},
7882
textAnchor: 'middle',

0 commit comments

Comments
 (0)