diff --git a/packages/@ourworldindata/grapher/src/lineCharts/LineChart.tsx b/packages/@ourworldindata/grapher/src/lineCharts/LineChart.tsx index 8a87922921..24407890d8 100644 --- a/packages/@ourworldindata/grapher/src/lineCharts/LineChart.tsx +++ b/packages/@ourworldindata/grapher/src/lineCharts/LineChart.tsx @@ -31,7 +31,7 @@ import { select } from "d3-selection" import { easeLinear } from "d3-ease" import { DualAxisComponent } from "../axis/AxisViews" import { DualAxis, HorizontalAxis, VerticalAxis } from "../axis/Axis" -import { LineLegend, LineLabelSeries } from "../lineLegend/LineLegend" +import { LineLegend } from "../lineLegend/LineLegend" import { ComparisonLine } from "../scatterCharts/ComparisonLine" import { TooltipFooterIcon } from "../tooltip/TooltipProps.js" import { @@ -115,6 +115,7 @@ import { getSeriesName, } from "./LineChartHelpers" import { FocusArray } from "../focus/FocusArray.js" +import { LineLabelSeries } from "../lineLegend/LineLegendTypes" const LINE_CHART_CLASS_NAME = "LineChart" diff --git a/packages/@ourworldindata/grapher/src/lineLegend/LineLegend.tsx b/packages/@ourworldindata/grapher/src/lineLegend/LineLegend.tsx index a7686cfde0..fb06cefd9f 100644 --- a/packages/@ourworldindata/grapher/src/lineLegend/LineLegend.tsx +++ b/packages/@ourworldindata/grapher/src/lineLegend/LineLegend.tsx @@ -18,12 +18,10 @@ import { VerticalAxis } from "../axis/Axis" import { Color, EntityName, - InteractionState, SeriesName, VerticalAlign, } from "@ourworldindata/types" import { BASE_FONT_SIZE, GRAPHER_FONT_SCALE_12 } from "../core/GrapherConstants" -import { ChartSeries } from "../chart/ChartInterface" import { darkenColorForText } from "../color/ColorUtils" import { AxisConfig } from "../axis/AxisConfig.js" import { GRAPHER_BACKGROUND_DEFAULT, GRAY_30 } from "../color/ColorConstants" @@ -40,35 +38,7 @@ import { NON_FOCUSED_TEXT_COLOR, } from "./LineLegendConstants.js" import { getSeriesKey } from "./LineLegendHelpers" - -export interface LineLabelSeries extends ChartSeries { - label: string - yValue: number - annotation?: string - formattedValue?: string - placeFormattedValueInNewLine?: boolean - yRange?: [number, number] - hover?: InteractionState - focus?: InteractionState -} - -interface SizedSeries extends LineLabelSeries { - textWrap: TextWrap | MarkdownTextWrap - textWrapForRendering: TextWrap | MarkdownTextWrap - annotationTextWrap?: TextWrap - width: number - height: number - fontWeight?: number -} - -interface PlacedSeries extends SizedSeries { - origBounds: Bounds - bounds: Bounds - repositions: number - level: number - totalLevels: number - midY: number -} +import { LineLabelSeries, PlacedSeries, SizedSeries } from "./LineLegendTypes" function groupBounds(group: PlacedSeries[]): Bounds { const first = group[0] diff --git a/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx b/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx index b713209ebf..180c945701 100644 --- a/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx +++ b/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx @@ -64,11 +64,7 @@ import { NoDataSection } from "../scatterCharts/NoDataSection" import { CategoricalColorAssigner } from "../color/CategoricalColorAssigner" import { ColorScheme } from "../color/ColorScheme" import { ColorSchemes } from "../color/ColorSchemes" -import { - LineLabelSeries, - LineLegend, - LineLegendProps, -} from "../lineLegend/LineLegend" +import { LineLegend, LineLegendProps } from "../lineLegend/LineLegend" import { makeTooltipRoundingNotice, makeTooltipToleranceNotice, @@ -94,6 +90,7 @@ import { GRAPHER_DARK_TEXT, } from "../color/ColorConstants" import { FocusArray } from "../focus/FocusArray" +import { LineLabelSeries } from "../lineLegend/LineLegendTypes" type SVGMouseOrTouchEvent = | React.MouseEvent diff --git a/packages/@ourworldindata/grapher/src/stackedCharts/StackedAreaChart.tsx b/packages/@ourworldindata/grapher/src/stackedCharts/StackedAreaChart.tsx index 538f16d368..6c2f28c103 100644 --- a/packages/@ourworldindata/grapher/src/stackedCharts/StackedAreaChart.tsx +++ b/packages/@ourworldindata/grapher/src/stackedCharts/StackedAreaChart.tsx @@ -29,7 +29,7 @@ import { import { observer } from "mobx-react" import { DualAxisComponent } from "../axis/AxisViews" import { DualAxis } from "../axis/Axis" -import { LineLabelSeries, LineLegend } from "../lineLegend/LineLegend" +import { LineLegend } from "../lineLegend/LineLegend" import { NoDataModal } from "../noDataModal/NoDataModal" import { TooltipFooterIcon } from "../tooltip/TooltipProps.js" import { @@ -57,6 +57,7 @@ import { } from "../chart/ChartUtils" import { bind } from "decko" import { AxisConfig } from "../axis/AxisConfig.js" +import { LineLabelSeries } from "../lineLegend/LineLegendTypes" interface AreasProps extends React.SVGAttributes { dualAxis: DualAxis