Skip to content

Commit

Permalink
Added onclick pointer to bar chart/histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
SanjeevLakhwani committed Nov 21, 2024
1 parent 50ea993 commit 3ae584d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/js/components/Overview/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useTranslationFn } from '@/hooks';
import type { ChartData } from '@/types/data';
import type { ChartConfig } from '@/types/chartConfig';
import { CHART_TYPE_BAR, CHART_TYPE_CHOROPLETH, CHART_TYPE_HISTOGRAM, CHART_TYPE_PIE } from '@/types/chartConfig';
import { noop } from '@/utils/chart';

interface BarChartEvent {
activePayload: Array<{ payload: { x: string; id?: string } }>;
Expand Down Expand Up @@ -48,7 +49,7 @@ const Chart = memo(({ chartConfig, data, units, id, isClickable }: ChartProps) =
units={units}
preFilter={removeMissing}
dataMap={translateMap}
{...(isClickable ? { onChartClick: barChartOnChartClickHandler } : {})}
{...(isClickable ? { onChartClick: barChartOnChartClickHandler, onClick: noop } : {})}
/>
);
case CHART_TYPE_HISTOGRAM:
Expand All @@ -59,7 +60,7 @@ const Chart = memo(({ chartConfig, data, units, id, isClickable }: ChartProps) =
data={data}
preFilter={removeMissing}
dataMap={translateMap}
{...(isClickable ? { onChartClick: barChartOnChartClickHandler } : {})}
{...(isClickable ? { onChartClick: barChartOnChartClickHandler, onClick: noop } : {})}
/>
);
case CHART_TYPE_PIE:
Expand Down
2 changes: 2 additions & 0 deletions src/js/utils/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ import type { ChartData } from '@/types/data';
export const serializeChartData = (chartData: Datum[]): ChartData[] => {
return chartData.map(({ label, value }) => ({ x: label, y: value }));
};

export const noop = () => {};

0 comments on commit 3ae584d

Please sign in to comment.