From 47945ae2339dff4679ead1d388ca5651dfec9a44 Mon Sep 17 00:00:00 2001 From: sophiamersmann Date: Mon, 2 Dec 2024 15:29:41 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20(slope)=20incorporate=20pr=20feedba?= =?UTF-8?q?ck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../grapher/src/slopeCharts/SlopeChart.tsx | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx b/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx index 7e10f64669..4f2130bf8d 100644 --- a/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx +++ b/packages/@ourworldindata/grapher/src/slopeCharts/SlopeChart.tsx @@ -335,7 +335,7 @@ export class SlopeChart // if tolerance has been applied to one of the values, then we require // a minimal distance between the original times if (isToleranceAppliedToStartValue || isToleranceAppliedToEndValue) { - return end.originalTime - start.originalTime >= 2 * tolerance + return end.originalTime - start.originalTime >= tolerance } return true @@ -692,25 +692,17 @@ export class SlopeChart const formatTime = (time: Time) => formatColumn.formatTime(time) - const title = isRelativeMode - ? `${series.seriesName}, ${formatColumn.formatTime(endTime)}` - : series.seriesName - - const isStartValueOriginal = series.start.originalTime === startTime - const isEndValueOriginal = series.end.originalTime === endTime - const actualStartTime = isStartValueOriginal - ? startTime - : series.start.originalTime - const actualEndTime = isEndValueOriginal - ? endTime - : series.end.originalTime - + const actualStartTime = series.start.originalTime + const actualEndTime = series.end.originalTime const timeRange = `${formatTime(actualStartTime)} to ${formatTime(actualEndTime)}` const timeLabel = isRelativeMode - ? `% change since ${formatColumn.formatTime(startTime)}` + ? `% change between ${formatColumn.formatTime(actualStartTime)} and ${formatColumn.formatTime(actualEndTime)}` : timeRange const constructTargetYearForToleranceNotice = () => { + const isStartValueOriginal = series.start.originalTime === startTime + const isEndValueOriginal = series.end.originalTime === endTime + if (!isStartValueOriginal && !isEndValueOriginal) { return `${formatTime(startTime)} and ${formatTime(endTime)}` } else if (!isStartValueOriginal) { @@ -753,7 +745,7 @@ export class SlopeChart offsetX={20} offsetY={-16} style={{ maxWidth: "250px" }} - title={title} + title={series.seriesName} subtitle={timeLabel} subtitleFormat={targetYear ? "notice" : undefined} dissolve={fading}