Skip to content

Commit

Permalink
🐝 (grapher) refactor horizontal axis views (#3274)
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann authored Mar 4, 2024
2 parents b36c9b7 + a1f65c2 commit a569075
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions packages/@ourworldindata/grapher/src/axis/AxisViews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ export class HorizontalAxisGridLines extends React.Component<{
render(): JSX.Element {
const { horizontalAxis, strokeWidth } = this.props
const { bounds } = this
const axis = horizontalAxis.clone()
axis.range = bounds.xRange()

return (
<g className={classNames("AxisGridLines", "verticalLines")}>
{horizontalAxis.getTickValues().map((t, i) => {
{axis.getTickValues().map((t, i) => {
const color = t.faint
? FAINT_TICK_COLOR
: t.solid
Expand All @@ -95,9 +97,9 @@ export class HorizontalAxisGridLines extends React.Component<{
return (
<line
key={i}
x1={horizontalAxis.place(t.value)}
x1={axis.place(t.value)}
y1={bounds.bottom.toFixed(2)}
x2={horizontalAxis.place(t.value)}
x2={axis.place(t.value)}
y2={bounds.top.toFixed(2)}
stroke={color}
strokeWidth={strokeWidth}
Expand All @@ -124,6 +126,8 @@ export class HorizontalAxisZeroLine extends React.Component<{
}> {
render(): JSX.Element {
const { bounds, horizontalAxis, strokeWidth } = this.props
const axis = horizontalAxis.clone()
axis.range = bounds.xRange()

return (
<g
Expand All @@ -134,9 +138,9 @@ export class HorizontalAxisZeroLine extends React.Component<{
)}
>
<line
x1={horizontalAxis.place(0)}
x1={axis.place(0)}
y1={bounds.bottom.toFixed(2)}
x2={horizontalAxis.place(0)}
x2={axis.place(0)}
y2={bounds.top.toFixed(2)}
stroke={SOLID_TICK_COLOR}
strokeWidth={strokeWidth}
Expand Down

0 comments on commit a569075

Please sign in to comment.