question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Donut - Label error when hovering a slice

See original GitHub issue

Hi! 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:closed
  • Created 5 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
junedchhipacommented, Mar 13, 2019

Thanks for the detailed report. I will fix it soon.

0reactions
junedchhipacommented, Mar 20, 2019

Thanks, @xomin70 Added the check.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found