From 196784fb8109fbab846169234cf77b269543f53c Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Fri, 22 Nov 2024 14:06:19 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20(slope)=20fix=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grapher/src/lineCharts/lineChartHelpers.ts | 2 +- .../grapher/src/slopeCharts/SlopeChart.test.ts | 18 +++++------------- .../grapher/src/slopeCharts/SlopeChart.tsx | 2 +- 3 files changed, 7 insertions(+), 15 deletions(-) diff --git a/packages/@ourworldindata/grapher/src/lineCharts/lineChartHelpers.ts b/packages/@ourworldindata/grapher/src/lineCharts/lineChartHelpers.ts index 5296a3a3eca..74fdccc4c52 100644 --- a/packages/@ourworldindata/grapher/src/lineCharts/lineChartHelpers.ts +++ b/packages/@ourworldindata/grapher/src/lineCharts/lineChartHelpers.ts @@ -27,7 +27,7 @@ export function getSeriesName({ // if columns are plotted, use the column name // and prepend the entity name if multiple entities can be selected - return availableEntityNames.length > 1 && canSelectMultipleEntities + return availableEntityNames.length > 1 || canSelectMultipleEntities ? `${entityName} - ${columnName}` : columnName } diff --git a/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.test.ts b/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.test.ts index 9a22d9c08a6..c1cb8586a7f 100755 --- a/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.test.ts +++ b/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.test.ts @@ -7,28 +7,20 @@ import { SynthesizeGDPTable, } from "@ourworldindata/core-table" import { ChartManager } from "../chart/ChartManager" -import { DEFAULT_SLOPE_CHART_COLOR } from "./SlopeChartConstants" -import { isNumber, OwidTableSlugs } from "@ourworldindata/utils" +import { isNumber } from "@ourworldindata/utils" const table = SynthesizeGDPTable({ timeRange: [2000, 2010] }) const manager: ChartManager = { table, yColumnSlug: SampleColumnSlugs.Population, + selection: table.availableEntityNames, + startTime: 2000, + endTime: 2009, } it("can create a new slope chart", () => { const chart = new SlopeChart({ manager }) - expect(chart.series.length).toEqual(2) -}) - -it("slope charts can have different colors", () => { - const manager: ChartManager = { - table, - yColumnSlug: SampleColumnSlugs.Population, - colorColumnSlug: OwidTableSlugs.entityName, - } - const chart = new SlopeChart({ manager }) - expect(chart.series[0].color).not.toEqual(DEFAULT_SLOPE_CHART_COLOR) + expect(chart.series).toEqual(2) }) it("filters non-numeric values", () => { diff --git a/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx b/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx index 44720736c34..11090b8d44d 100644 --- a/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx +++ b/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx @@ -396,7 +396,7 @@ export class SlopeChart return map } - @computed private get series(): SlopeChartSeries[] { + @computed get series(): SlopeChartSeries[] { return this.rawSeries.filter((series) => this.shouldSeriesBePlotted(series) )