Skip to content

Commit

Permalink
✨ (axis) center-align axis labels (#3665)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann authored May 30, 2024
1 parent e87713d commit 28d89e0
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions packages/@ourworldindata/grapher/src/axis/AxisViews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ export class VerticalAxisComponent extends React.Component<{
>
{labelTextWrap &&
labelTextWrap.renderSVG(
-verticalAxis.rangeCenter - labelTextWrap.width / 2,
-verticalAxis.rangeCenter,
bounds.left,
{
id: makeIdForHumanConsumption(
Expand All @@ -278,6 +278,7 @@ export class VerticalAxisComponent extends React.Component<{
textProps: {
transform: "rotate(-90)",
fill: labelColor || GRAPHER_DARK_TEXT,
textAnchor: "middle",
},
detailsMarker,
}
Expand Down Expand Up @@ -389,19 +390,14 @@ export class HorizontalAxisComponent extends React.Component<{
className="HorizontalAxis"
>
{label &&
label.renderSVG(
axis.rangeCenter - label.width / 2,
labelYPosition,
{
id: makeIdForHumanConsumption(
"horizontal-axis-label"
),
textProps: {
fill: labelColor || GRAPHER_DARK_TEXT,
},
detailsMarker,
}
)}
label.renderSVG(axis.rangeCenter, labelYPosition, {
id: makeIdForHumanConsumption("horizontal-axis-label"),
textProps: {
fill: labelColor || GRAPHER_DARK_TEXT,
textAnchor: "middle",
},
detailsMarker,
})}
{tickLabels.map((label) => {
const { x, xAlign, formattedValue } = label
return (
Expand Down

0 comments on commit 28d89e0

Please sign in to comment.