nivo icon indicating copy to clipboard operation
nivo copied to clipboard

Get exact clicked data point in chart

Open saeedesmaili opened this issue 1 year ago • 1 comments

I'm using the Nivo chart library in one of my projects and I've found it to be very useful. However, I've encountered a situation where I need to get the exact data point that a user clicks on in a chart.

Currently, when a user clicks on a point, the onClick event returns an array of all data points. While this is helpful for many use cases, in my situation, I need to know the specific point that was clicked.

For example, in a bump chart, when I click on a data point and log the returned value using onClick, I get: image

It returned the values of this data point for all x-axes (2007 - end), but I have clicked on the data point in the 2010 column, and I want a way to know which exact data point is clicked (so I can filter the data and display a monthly chart for that specific year).

I was wondering if it might be possible to add this functionality or if is there already a way to achieve this.

saeedesmaili avatar Jan 09 '24 12:01 saeedesmaili

Hey @saeedesmaili Bump chart specifically does not have this functionality. You could add a "Mesh" layer to achieve this. I created this PR to address the issue, but haven't received any comments so far. In the meantime you could use the code there in your own codebase.

santiperone avatar Jan 18 '24 03:01 santiperone

@saeedesmaili, the PR from @santiperone has been merged, it'll be released soon.

plouc avatar May 01 '24 05:05 plouc

Thank you!

saeedesmaili avatar May 01 '24 06:05 saeedesmaili