From c3db031deca82613ea566145b662238c56ab03a7 Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Mon, 30 Oct 2023 09:58:31 +0000 Subject: [PATCH] fix: guard against an empty list of tables --- .../grapher/src/stackedCharts/AbstractStackedChart.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/@ourworldindata/grapher/src/stackedCharts/AbstractStackedChart.tsx b/packages/@ourworldindata/grapher/src/stackedCharts/AbstractStackedChart.tsx index dc82f986683..284da9838e3 100644 --- a/packages/@ourworldindata/grapher/src/stackedCharts/AbstractStackedChart.tsx +++ b/packages/@ourworldindata/grapher/src/stackedCharts/AbstractStackedChart.tsx @@ -24,7 +24,11 @@ import { StackedRawSeries, StackedSeries, } from "./StackedConstants" -import { OwidTable, CoreColumn } from "@ourworldindata/core-table" +import { + OwidTable, + CoreColumn, + BlankOwidTable, +} from "@ourworldindata/core-table" import { autoDetectSeriesStrategy, autoDetectYColumnSlugs, @@ -103,6 +107,9 @@ export class AbstractStackedChart .map((t: OwidTable) => t.dropRowsWithErrorValuesForAnyColumn(this.yColumnSlugs) ) + + if (groupedByEntity.length === 0) return BlankOwidTable() + table = groupedByEntity[0].concat(groupedByEntity.slice(1)) }