Relative Content

Tag Archive for reactjsapexcharts

React setstate inside ApexChart event

I am trying to set a variable to the selected data point inside of an ApexChart Heatmap. However calling setState crashes with an error of “TypeError: Cannot read properties of null (reading ‘getBoundingClientRect’)” even though the data is definitely not null. Funnily enough, adding a setTimout() and calling the set state from there works but it is too slow to be useful.

The react apex chart is not working as expected

useEffect(() => { const fetchData = async () => { try { const response = await axios.get(‘api’); setGraphValue(response.data); const series = [ { name: ‘success’, data: [], color: ‘#C4BFBE’ }, { name: ‘failure’, data: [], color: ‘#FF0000’ }, ]; series[index].data.push({ x: i >= 12 ? i + ‘ pm’ : i + ‘ am’, y: […]