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,