Donut - Label error when hovering a slice
See original GitHub issueHi! I’m getting this error when the cursor leaves a slice:
Uncaught TypeError: Cannot read property ‘style’ of null at Pie.revertDataLabelsInner (apexcharts.esm.js:8392)
import React, { memo } from 'react';
import Chart from 'react-apexcharts';
import styles from './pieChart.module.scss';
export default memo(function PieChart() {
const chartOptions = {
options: {
dataLabels: {
enabled: false
},
colors: ['#C7F464', '#662E9B', '#E2C044', '#C4BBAF'],
fill: {
type: 'gradient',
},
labels: ['Voice mail', 'Recordings', 'System', 'Free'],
legend: {
formatter: (_, opts) => chartOptions.labels[opts.seriesIndex],
itemMargin: {
horizontal: 5,
vertical: 10
},
position: 'bottom',
floating: true,
offsetY: -15
},
plotOptions: {
pie: {
expandOnClick: false
}
},
tooltip: {
enabled: true
}
},
series: [44, 55, 41, 17],
labels: ['Voice mail', 'Recordings', 'System', 'Free']
};
return (
<div className={styles.container}>
<Chart options={chartOptions.options} series={chartOptions.series} type="donut" />
</div>
);
});
In the function revertDataLabelsInner you search for all the elements that have .apexcharts-datalabels-group class, getting null as result. When comparing that in line 8391 you enter the condition even though dataLabelsGroup is null.
However, I’ve tried to reproduce the situation in https://codesandbox.io/s/m380n2nomj and nothing happens, it works perfectly.
Hope you can help me, thanks!
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Highcharts. Dynamic labels inside donut chart on mouseOver
Label inside donut chart changing on mouse over. Color depending on data. Styling label to look like the picture.
Read more >How to Make a Pie Chart Slice Standout on Hover in Chart js
How to Make a Pie Chart Slice Standout on Hover in Chart jsIn this video we will cover how to make a pie...
Read more >How to Highlight Corresponding Doughnut Section on Legend ...
How to highlight corresponding doughnut section when you hover over legend in Chart.JS 3In this video we will explore how to highlight the ......
Read more >Visualization: Pie Chart - Google Developers
Displays tooltips when hovering over slices. ... If you have a donut chart with just one slice, the center of the slice may...
Read more >Donut Chart - Login | Domo
When this option is selected, the "hover legend," which normally appears when you mouse over a slice in your pie or donut chart, ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the detailed report. I will fix it soon.
Thanks, @xomin70 Added the check.