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.

Click events doesn't generate dataPointIndex and seriesIndex for Pie Charts

See original GitHub issue

Bug report

Codepen

https://codepen.io/MadBoyEvo/pen/ExNbVeo

Explanation

  • What is the behavior you expect?

Both dataPointSelection and click event should return dataPointindex or/and series for all types of events correctly.

  • What is happening instead?

Following code behaves differently for different charts. For Pie charts only dataPointSelection provides dataPointIndex, but click event always return -1, -1. Click event for bar chart works correctly so I’m assuming this is a bug, not a feature. Maybe other chart types have the same issue.

events: {
    dataPointSelection: function (event, chartContext, config) {
        console.log(config.dataPointIndex + " " + config.seriesIndex);
    },
    click: function (event, chartContext, config) {
        console.log(config.dataPointIndex + " " + config.seriesIndex);
    }
}
  • What error message are you getting?

No error message.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:11

github_iconTop GitHub Comments

2reactions
gbenga504commented, Aug 24, 2021

Yeah this is a bug. I think you can get around this by using event.target.parentElement.getAttribute("data:realIndex")

i.e

 chart: {
      type: 'pie',
      events: {
        click: function(event, chartContext, config) {
            console.log(event.target.parentElement.getAttribute("data:realIndex"))
        }
      }
    },
0reactions
ayudh37commented, Jul 6, 2022

any idea? I’m getting config.dataPointIndex as -1 while hovering over a line graph

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - pie chart seriesIndex and dataPointIndex are
To get a reference to a pie slice clicked on you'll want to use the dataPointSelection function instead. This allows you to get...
Read more >
ApexCharts - Pie Chart problem with Click Event - CodePen
Insecure Resource. The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https....
Read more >
Button on click does not display pie charts - GIS Stack Exchange
In order for the button to work, the drawChart() function needs to be used in the HTML without any arguments. You must also...
Read more >
events - ApexCharts.js
Fires when user clicks on the markers. chart: { events: { markerClick: function(event, chartContext, { seriesIndex, dataPointIndex, ...
Read more >
TMS IntraWeb HTML5 Controls Pack Developers Guide
The chart also heavily implements asynchronous updates and events. ... This enables to show 360° pie charts, 180° pie charts or other.
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