Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added onclick pointer to bar chart/histogram #227

Merged
merged 4 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = () => {};