Skip to content

Commit 2e26430

Browse files
authored
fix(axis): rotated label positioning (#709)
Fix title positioning when using rotated tick labels fixes #673
1 parent ed49bbb commit 2e26430

7 files changed

Lines changed: 3 additions & 3 deletions
Loading
-8 Bytes
Loading
-6 Bytes
Loading
-2 Bytes
Loading
-9 Bytes
Loading

src/chart_types/xy_chart/renderer/canvas/axes/title.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function renderVerticalTitle(ctx: CanvasRenderingContext2D, props: AxisProps) {
4242
const {
4343
axisPosition: { height },
4444
axisSpec: { title, position, tickSize, tickPadding },
45-
axisTicksDimensions: { maxLabelTextWidth },
45+
axisTicksDimensions: { maxLabelBboxWidth },
4646
axisConfig: { axisTitleStyle },
4747
debug,
4848
} = props;
@@ -51,7 +51,7 @@ function renderVerticalTitle(ctx: CanvasRenderingContext2D, props: AxisProps) {
5151
}
5252
const { padding, ...titleStyle } = axisTitleStyle;
5353
const top = height;
54-
const left = position === Position.Left ? 0 : tickSize + tickPadding + maxLabelTextWidth + padding;
54+
const left = position === Position.Left ? 0 : tickSize + tickPadding + maxLabelBboxWidth + padding;
5555

5656
if (debug) {
5757
renderDebugRect(ctx, { x: left, y: top, width: height, height: titleStyle.fontSize }, undefined, undefined, -90);

stories/axes/2_tick_label_rotation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const Example = () => {
7575
id="right"
7676
title="Bar axis"
7777
position={Position.Right}
78-
tickLabelRotation={number('right axis tick label rotation', 0, {
78+
tickLabelRotation={number('right axis tick label rotation', -90, {
7979
range: true,
8080
min: -90,
8181
max: 90,

0 commit comments

Comments
 (0)