From 8bac63c5e6d923ec3ed58941f5d121b24daac893 Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Tue, 3 Dec 2024 11:05:50 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20type=20error?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grapher/src/lineLegend/LineLegend.tsx | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/packages/@ourworldindata/grapher/src/lineLegend/LineLegend.tsx b/packages/@ourworldindata/grapher/src/lineLegend/LineLegend.tsx index 4c602b4ee64..5e70c929e1d 100644 --- a/packages/@ourworldindata/grapher/src/lineLegend/LineLegend.tsx +++ b/packages/@ourworldindata/grapher/src/lineLegend/LineLegend.tsx @@ -381,17 +381,16 @@ export class LineLegend extends React.Component { const maxAnnotationWidth = Math.min(maxTextWidth, 150) return this.props.labelSeries.map((label) => { - const labelFragments = excludeUndefined([ - { text: label.label, fontWeight }, - label.formattedValue - ? { - text: label.formattedValue, - newLine: label.placeFormattedValueInNewLine - ? "always" - : "avoid-wrap", - } - : undefined, - ]) + const mainLabel = { text: label.label, fontWeight } + const valueLabel = label.formattedValue + ? { + text: label.formattedValue, + newLine: (label.placeFormattedValueInNewLine + ? "always" + : "avoid-wrap") as "always" | "avoid-wrap", + } + : undefined + const labelFragments = excludeUndefined([mainLabel, valueLabel]) const textWrap = new TextWrapGroup({ fragments: labelFragments, maxWidth: maxTextWidth,