Skip to content

Commit

Permalink
💄 (grapher) rename dodMarker -> detailsMarker
Browse files Browse the repository at this point in the history
  • Loading branch information
sophiamersmann committed Mar 6, 2024
1 parent e16f4d6 commit 4c73b35
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -642,15 +642,15 @@ export class MarkdownTextWrap extends React.Component<MarkdownTextWrapProps> {
y: number,
{
textProps,
dodMarker = "superscript",
detailsMarker = "superscript",
}: {
textProps?: React.SVGProps<SVGTextElement>
dodMarker?: DetailsMarker
detailsMarker?: DetailsMarker
} = {}
): JSX.Element | null {
const { fontSize, lineHeight } = this
const lines =
dodMarker === "superscript"
detailsMarker === "superscript"
? this.svgLinesWithDodReferenceNumbers
: this.svgLines
if (lines.length === 0) return null
Expand Down Expand Up @@ -690,7 +690,7 @@ export class MarkdownTextWrap extends React.Component<MarkdownTextWrapProps> {
))}
</text>
{/* SVG doesn't support dotted underlines, so we draw them manually */}
{dodMarker === "underline" &&
{detailsMarker === "underline" &&
lines.map((line, lineIndex) => {
const y = (getLineY(lineIndex) + 2).toFixed(1)
let currWidth = 0
Expand Down
20 changes: 10 additions & 10 deletions packages/@ourworldindata/grapher/src/axis/AxisViews.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ interface DualAxisViewProps {
labelColor?: string
tickColor?: string
lineWidth?: number
dodMarker?: DetailsMarker
detailsMarker?: DetailsMarker
}

@observer
Expand All @@ -169,7 +169,7 @@ export class DualAxisComponent extends React.Component<DualAxisViewProps> {
labelColor,
tickColor,
lineWidth,
dodMarker,
detailsMarker,
} = this.props
const { bounds, horizontalAxis, verticalAxis, innerBounds } = dualAxis

Expand All @@ -195,7 +195,7 @@ export class DualAxisComponent extends React.Component<DualAxisViewProps> {
verticalAxis={verticalAxis}
labelColor={labelColor}
tickColor={tickColor}
dodMarker={dodMarker}
detailsMarker={detailsMarker}
/>
)

Expand All @@ -208,7 +208,7 @@ export class DualAxisComponent extends React.Component<DualAxisViewProps> {
labelColor={labelColor}
tickColor={tickColor}
tickMarkWidth={lineWidth}
dodMarker={dodMarker}
detailsMarker={detailsMarker}
/>
)

Expand All @@ -229,10 +229,10 @@ export class VerticalAxisComponent extends React.Component<{
verticalAxis: VerticalAxis
labelColor?: string
tickColor?: string
dodMarker?: DetailsMarker
detailsMarker?: DetailsMarker
}> {
render(): JSX.Element {
const { bounds, verticalAxis, labelColor, tickColor, dodMarker } =
const { bounds, verticalAxis, labelColor, tickColor, detailsMarker } =
this.props
const { tickLabels, labelTextWrap } = verticalAxis

Expand All @@ -247,7 +247,7 @@ export class VerticalAxisComponent extends React.Component<{
transform: "rotate(-90)",
fill: labelColor || GRAPHER_DARK_TEXT,
},
dodMarker,
detailsMarker,
}
)}
{tickLabels.map((label, i) => {
Expand Down Expand Up @@ -285,7 +285,7 @@ export class HorizontalAxisComponent extends React.Component<{
labelColor?: string
tickColor?: string
tickMarkWidth?: number
dodMarker?: DetailsMarker
detailsMarker?: DetailsMarker
}> {
@computed get scaleType(): ScaleType {
return this.props.axis.scaleType
Expand All @@ -312,7 +312,7 @@ export class HorizontalAxisComponent extends React.Component<{
labelColor,
tickColor,
tickMarkWidth,
dodMarker,
detailsMarker,
} = this.props
const { tickLabels, labelTextWrap: label, labelOffset, orient } = axis
const horizontalAxisLabelsOnTop = orient === Position.top
Expand Down Expand Up @@ -348,7 +348,7 @@ export class HorizontalAxisComponent extends React.Component<{
textProps: {
fill: labelColor || GRAPHER_DARK_TEXT,
},
dodMarker,
detailsMarker,
}
)}
{tickMarks}
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/grapher/src/footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ export class StaticFooter extends Footer<StaticFooterProps> {
note.renderSVG(
targetX,
targetY + sources.height + this.verticalPadding,
{ dodMarker: this.manager.detailsMarkerInSvg }
{ detailsMarker: this.manager.detailsMarkerInSvg }
)}
{showLicenseNextToSources
? licenseAndOriginUrl.render(
Expand Down
2 changes: 1 addition & 1 deletion packages/@ourworldindata/grapher/src/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export class StaticHeader extends Header<StaticHeaderProps> {
textProps: {
fill: manager.secondaryColorInStaticCharts,
},
dodMarker: this.manager.detailsMarkerInSvg,
detailsMarker: this.manager.detailsMarkerInSvg,
}
)}
</g>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ export class LineChart
? GRAPHER_AXIS_LINE_WIDTH_THICK
: GRAPHER_AXIS_LINE_WIDTH_DEFAULT
}
dodMarker={manager.detailsMarkerInSvg}
detailsMarker={manager.detailsMarkerInSvg}
/>
<g clipPath={clipPath.id}>
{comparisonLines.map((line, index) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ export class ScatterPlotChart
? GRAPHER_AXIS_LINE_WIDTH_THICK
: GRAPHER_AXIS_LINE_WIDTH_DEFAULT
}
dodMarker={manager.detailsMarkerInSvg}
detailsMarker={manager.detailsMarkerInSvg}
/>
{comparisonLines &&
comparisonLines.map((line, i) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ export class MarimekkoChart
? GRAPHER_AXIS_LINE_WIDTH_THICK
: GRAPHER_AXIS_LINE_WIDTH_DEFAULT
}
dodMarker={manager.detailsMarkerInSvg}
detailsMarker={manager.detailsMarkerInSvg}
/>
<HorizontalCategoricalColorLegend manager={this} />
{this.renderBars()}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ export class StackedAreaChart
? GRAPHER_AXIS_LINE_WIDTH_THICK
: GRAPHER_AXIS_LINE_WIDTH_DEFAULT
}
dodMarker={manager.detailsMarkerInSvg}
detailsMarker={manager.detailsMarkerInSvg}
/>
<g clipPath={clipPath.id}>
{showLegend && <LineLegend manager={this} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ export class StackedBarChart
bounds={bounds}
verticalAxis={verticalAxis}
labelColor={manager.secondaryColorInStaticCharts}
dodMarker={manager.detailsMarkerInSvg}
detailsMarker={manager.detailsMarkerInSvg}
/>
<VerticalAxisGridLines
verticalAxis={verticalAxis}
Expand Down
10 changes: 6 additions & 4 deletions packages/@ourworldindata/types/src/grapherTypes/GrapherTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ export enum KeyChartLevel {
Top = 3, // chart will show at the top of the all charts block
}

// How to mark a detail on demand
// - superscript: add a superscript reference number
// - underline: underline the text
// - none: don't mark it
/**
* How to mark a detail on demand:
* - superscript: add a superscript reference number
* - underline: underline the text
* - none: don't mark it
*/
export type DetailsMarker = "superscript" | "underline" | "none"

export interface BasicChartInformation {
Expand Down

0 comments on commit 4c73b35

Please sign in to comment.