react-apexcharts
react-apexcharts copied to clipboard
Error "Cannot read property 'getAttribute' of null" when trying to update state from event "dataPointSelection"
Hello,
I have also posted this in this apexcharts issue but it is probably more suited to the react-apexcharts
repository.
I have this problem when I want to update the series when a data point is clicked.
You can see it in this Codesandbox
Am I updating the state correctly, or should I do it another way?
I also tried to update my chart using
ApexCharts.exec('donut', 'updateSeries', [{
data: [40, 55, 65, 11, 23, 44, 54, 33]
}])
But I get the same error.
Many thanks!
Hey @akmur, I'm getting the same error when trying to change state of another component on hovering the polar chart. Were you able to solve this issue ?? Any help would be helpful.
Thanks 👍
Has anyone solved this problem?
Yes, you need to setTimeout
chart: { events: { dataPointSelection: (event, chartContext, config) => setTimeout(() => {smth.onClick(), 1000}); } } },
May not work for everyone, but was able to resolve this by wrapping options object with React.useMemo().