apexcharts / react-apexcharts

📊 React Component for ApexCharts
https://apexcharts.com
MIT License
1.31k stars 158 forks source link

toggleDataPointSelection does not seem to work #248

Closed KristofVDB1 closed 2 months ago

KristofVDB1 commented 3 years ago

Hi

I've been trying for a while now to get the toggleDataPointSelection to work but it's not working for me.

I'm using "react-apexcharts": "^1.3.7" and "apexcharts": "^3.23.1",.

This is the code I'm currently using:

import Chart from 'react-apexcharts';
import ApexCharts from 'apexcharts';

    this.state = {
      options: {
        chart: {
          id: 'genderplot',
          events: {
            dataPointSelection: (event, context, config) => {
              this.updateFilters(event, context, config);
            },
          },
        },
        xaxis: {
          categories: ['male', 'female', 'other'],
        },
        plotOptions: {
          bar: {
            horizontal: true,
          },
        },
      },
      series: [{
        name: 'gender',
        data: [m, f, u],
      }],
    };

<Chart options={this.state.options} series={this.state.series} type="bar" />

ApexCharts.exec('genderplot', 'toggleDataPointSelection', {
        seriesIndex: 0,
        dataPointIndex: 1,
});

I've tried passing the two indexes in different manners but without any success. Other methods using exec have worked, so I don't think there will be an issue there.

The issue I'm getting in the console: image

Any help would be appreciated

rpieciorak commented 3 years ago

It's working fine, you have to call it proper

const seriesIndex = 0;
const dataPointIndex = 0;
ApexCharts.exec('genderplot', 'toggleDataPointSelection', seriesIndex, dataPointIndex);

See ApexCharts docs

github-actions[bot] commented 2 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.