Skip to content

Commit

Permalink
changed line chart click logic
Browse files Browse the repository at this point in the history
  • Loading branch information
severinlandolt committed Sep 20, 2023
1 parent 65d5aee commit 3cdcdc1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/components/chart-elements/LineChart/LineChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((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,
Expand All @@ -92,12 +94,11 @@ const LineChart = React.forwardRef<HTMLDivElement, LineChartProps>((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 {
Expand Down

0 comments on commit 3cdcdc1

Please sign in to comment.