Skip to content

Donut - Label error when hovering a slice #403

@ortigozamatias

Description

@ortigozamatias

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions