Skip to content

Commit

Permalink
fix(Charts): fix onDataPointClick event not firing or firing for wron…
Browse files Browse the repository at this point in the history
…g segment on Donut/PieChart (#524)
  • Loading branch information
vbersch authored and MarcusNotheis committed May 19, 2020
1 parent ef22d2e commit e3475e0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions packages/charts/src/components/PieChart/PieChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,15 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a
const onItemLegendClick = useLegendItemClick(onLegendClick, () => measure.accessor);

const onDataPointClickInternal = useCallback(
(payload, event) => {
if (payload && payload?.activePayload && onDataPointClick) {
(payload, dataIndex, event) => {
if (payload && payload && typeof onDataPointClick === 'function') {
onDataPointClick(
enrichEventWithDetails(event, {
value: payload.activePayload[0].value,
dataKey: payload.activePayload[0].dataKey,
name: payload.activePayload[0].payload.name,
payload: payload.activePayload[0].payload,
dataIndex: payload.activeTooltipIndex
value: payload.value,
dataKey: payload.tooltipPayload?.[0]?.dataKey,
name: payload.name,
payload: payload.payload,
dataIndex
})
);
}
Expand All @@ -145,11 +145,11 @@ const PieChart: FC<PieChartProps> = forwardRef((props: PieChartProps, ref: Ref<a
resizeDebounce={chartConfig.resizeDebounce}
>
<PieChartLib
onClick={onDataPointClickInternal}
margin={chartConfig.margin}
className={typeof onDataPointClick === 'function' ? 'has-click-handler' : undefined}
>
<Pie
onClick={onDataPointClickInternal}
innerRadius={chartConfig.innerRadius}
outerRadius={chartConfig.outerRadius}
paddingAngle={chartConfig.paddingAngle}
Expand Down

0 comments on commit e3475e0

Please sign in to comment.