Skip to content

Commit 08d1f83

Browse files
emmacunninghammarkov00
authored andcommitted
fix(axis): fix horizontal title positioning to account for title padding
12
1 parent ab7e974 commit 08d1f83

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/components/react_canvas/axis.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export class Axis extends React.PureComponent<AxisProps> {
177177
return null;
178178
}
179179
if (isHorizontal(position)) {
180-
return this.renderOriziontalAxisTitle();
180+
return this.renderHorizontalAxisTitle();
181181
}
182182
return this.renderVerticalAxisTitle();
183183
}
@@ -229,13 +229,13 @@ export class Axis extends React.PureComponent<AxisProps> {
229229
</Group>
230230
);
231231
}
232-
private renderOriziontalAxisTitle() {
232+
private renderHorizontalAxisTitle() {
233233
const {
234234
axisPosition: { width, height },
235235
axisSpec: { title, position, tickSize, tickPadding },
236236
axisTicksDimensions: { maxLabelBboxHeight },
237237
chartTheme: {
238-
axes: { titleFontSize },
238+
axes: { titleFontSize, titlePadding },
239239
},
240240
debug,
241241
} = this.props;
@@ -244,7 +244,10 @@ export class Axis extends React.PureComponent<AxisProps> {
244244
return;
245245
}
246246

247-
const top = position === Position.Top ? -maxLabelBboxHeight : maxLabelBboxHeight + tickPadding + tickSize;
247+
const top = position === Position.Top ?
248+
-maxLabelBboxHeight - titlePadding :
249+
maxLabelBboxHeight + tickPadding + tickSize + titlePadding;
250+
248251
const left = 0;
249252
return (
250253
<Group>

0 commit comments

Comments
 (0)