diff --git a/packages/@ourworldindata/grapher/src/axis/AxisViews.tsx b/packages/@ourworldindata/grapher/src/axis/AxisViews.tsx index 12dc378a726..79ce78ef866 100644 --- a/packages/@ourworldindata/grapher/src/axis/AxisViews.tsx +++ b/packages/@ourworldindata/grapher/src/axis/AxisViews.tsx @@ -227,15 +227,32 @@ export class DualAxisComponent extends React.Component { export class VerticalAxisComponent extends React.Component<{ bounds: Bounds verticalAxis: VerticalAxis + showTickMarks?: boolean labelColor?: string tickColor?: string detailsMarker?: DetailsMarker }> { render(): JSX.Element { - const { bounds, verticalAxis, labelColor, tickColor, detailsMarker } = - this.props + const { + bounds, + verticalAxis, + labelColor, + tickColor, + detailsMarker, + showTickMarks, + } = this.props const { tickLabels, labelTextWrap } = verticalAxis + const tickMarks = showTickMarks ? ( + + verticalAxis.place(label.value) + )} + tickMarkLeftPosition={bounds.left + verticalAxis.width} + color={SOLID_TICK_COLOR} + /> + ) : undefined + return ( {labelTextWrap && @@ -250,6 +267,7 @@ export class VerticalAxisComponent extends React.Component<{ detailsMarker, } )} + {tickMarks} {tickLabels.map((label, i) => { const { y, xAlign, yAlign, formattedValue } = label return ( @@ -325,7 +343,7 @@ export class HorizontalAxisComponent extends React.Component<{ : preferredAxisPosition ?? bounds.bottom const tickMarks = showTickMarks ? ( - axis.place(label.value) @@ -374,7 +392,7 @@ export class HorizontalAxisComponent extends React.Component<{ } } -export class AxisTickMarks extends React.Component<{ +export class HorizontalAxisTickMarks extends React.Component<{ tickMarkTopPosition: number tickMarkXPositions: number[] color: string @@ -400,3 +418,30 @@ export class AxisTickMarks extends React.Component<{ }) } } + +export class VerticalAxisTickMarks extends React.Component<{ + tickMarkLeftPosition: number + tickMarkYPositions: number[] + color: string + width?: number +}> { + render(): JSX.Element[] { + const { tickMarkYPositions, tickMarkLeftPosition, color, width } = + this.props + const tickSize = 5 + const tickRight = tickMarkLeftPosition + tickSize + return tickMarkYPositions.map((tickMarkPosition, index) => { + return ( + + ) + }) + } +} diff --git a/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx b/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx index 95ed3c08662..859aad2372d 100644 --- a/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx +++ b/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx @@ -1102,16 +1102,28 @@ class LabelledSlopes /> {this.yAxis.tickLabels.map((tick, i) => { + const y = yAxis.place(tick.value) return ( - + + {/* grid lines connecting the chart area to the axis */} + + {/* grid lines within the chart area */} + + ) })} @@ -1119,6 +1131,8 @@ class LabelledSlopes )} diff --git a/packages/@ourworldindata/grapher/src/stackedCharts/StackedBarChart.tsx b/packages/@ourworldindata/grapher/src/stackedCharts/StackedBarChart.tsx index c59f5ac01e9..6c5edc70e0c 100644 --- a/packages/@ourworldindata/grapher/src/stackedCharts/StackedBarChart.tsx +++ b/packages/@ourworldindata/grapher/src/stackedCharts/StackedBarChart.tsx @@ -12,7 +12,7 @@ import { } from "@ourworldindata/utils" import { VerticalAxisComponent, - AxisTickMarks, + HorizontalAxisTickMarks, VerticalAxisGridLines, } from "../axis/AxisViews" import { NoDataModal } from "../noDataModal/NoDataModal" @@ -458,7 +458,7 @@ export class StackedBarChart strokeWidth={axisLineWidth} /> - tick.bounds.centerX