Get exact clicked data point in chart
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:
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.
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.
@saeedesmaili, the PR from @santiperone has been merged, it'll be released soon.
Thank you!