Skip to content

Commit

Permalink
fix(D3 plugin): fix click event handler (#443)
Browse files Browse the repository at this point in the history
fix(D3 plugin): fix click event handler (#436)

fix(d3): fix click event handler
  • Loading branch information
kuzmadom authored Mar 1, 2024
1 parent 416993e commit 71801cf
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/plugins/d3/renderer/components/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,17 @@ export const Chart = (props: Props) => {
yScale,
svgContainer: svgRef.current,
});

const clickHandler = data.chart?.events?.click;
React.useEffect(() => {
if (data.chart?.events?.click) {
dispatcher.on('click-chart', data.chart?.events?.click);
if (clickHandler) {
dispatcher.on('click-chart', clickHandler);
}

return () => {
dispatcher.on('click-chart', null);
};
}, [dispatcher]);
}, [dispatcher, clickHandler]);

const boundsOffsetTop = chart.margin.top;
const boundsOffsetLeft = chart.margin.left + getWidthOccupiedByYAxis({preparedAxis: yAxis});
Expand Down

0 comments on commit 71801cf

Please sign in to comment.