react-apexcharts icon indicating copy to clipboard operation
react-apexcharts copied to clipboard

Error "Cannot read property 'getAttribute' of null" when trying to update state from event "dataPointSelection"

Open akmur opened this issue 4 years ago • 6 comments

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!

akmur avatar Aug 06 '20 10:08 akmur

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 👍

s-pcode avatar Aug 27 '21 05:08 s-pcode

Has anyone solved this problem?

hi5on9 avatar Nov 28 '22 03:11 hi5on9

Yes, you need to setTimeout chart: { events: { dataPointSelection: (event, chartContext, config) => setTimeout(() => {smth.onClick(), 1000}); } } },

IuliiaRybets avatar Feb 28 '23 12:02 IuliiaRybets

May not work for everyone, but was able to resolve this by wrapping options object with React.useMemo().

mwayne16 avatar Sep 25 '23 19:09 mwayne16