Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get exact clicked data point in chart #2497

Closed
saeedesmaili opened this issue Jan 9, 2024 · 3 comments
Closed

Get exact clicked data point in chart #2497

saeedesmaili opened this issue Jan 9, 2024 · 3 comments

Comments

@saeedesmaili
Copy link

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.

@santiperone
Copy link
Contributor

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.

@plouc
Copy link
Owner

plouc commented May 1, 2024

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

@plouc plouc closed this as completed May 1, 2024
@saeedesmaili
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants