From 3cdcdc1c9c89ee7eddffd51f60d75b32f90c9da7 Mon Sep 17 00:00:00 2001 From: Severin Landolt Date: Wed, 20 Sep 2023 19:05:41 +0200 Subject: [PATCH] changed line chart click logic --- src/components/chart-elements/LineChart/LineChart.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/chart-elements/LineChart/LineChart.tsx b/src/components/chart-elements/LineChart/LineChart.tsx index 45ab526e4..3f10ec49e 100644 --- a/src/components/chart-elements/LineChart/LineChart.tsx +++ b/src/components/chart-elements/LineChart/LineChart.tsx @@ -80,9 +80,11 @@ const LineChart = React.forwardRef((props, ref) if (!hasOnValueChange) return; if (data.index === activeDot?.index && data.dataKey === activeDot?.dataKey) { + setActiveLegend(undefined); setActiveDot(undefined); onValueChange?.(null); } else { + setActiveLegend(data.dataKey); setActiveDot({ index: data.index, dataKey: data.dataKey, @@ -92,12 +94,11 @@ const LineChart = React.forwardRef((props, ref) categoryClicked: data.dataKey, }); } - setActiveLegend(undefined); } function onCategoryClick(dataKey: string) { if (!hasOnValueChange) return; - if (dataKey === activeLegend) { + if (dataKey === activeLegend && !activeDot) { setActiveLegend(undefined); onValueChange?.(null); } else {