Implement IHittable for BarPlot
See original GitHub issueFeature Suggestion
First, thanks for making such amazing library. I love it.
Second, we are currently implementing charts in our business accounting application. They look amazing. For scatter plots we use the method described in Highlight the Data Point Near the Cursor to display details about every transaction in the side panel. It works like a charm.
The problem arises with bar plots. Since there is no MouseOver method, or any way to detect collisions with the figure:
We would like to display information when the user hovers over one bar.
It would be pretty easy to detect mouse over one square, but the problem is that there are so may variables that controls the positioning of each bar that it becomes a bit difficult. Also, all the position calculation is done in the Draw method, so there is no way to retrieve the current position and size of each bar.
Feature description:
My suggestion would be to implement the IHitable interface in the BarPlot class. I think it would be pretty easy. The same that is done for the Tooltip can be done:
- Inside the draw method store in a private variable the position and size of each bar.
- In the IHittable.HitTest() method, use that information from the last render to perform a point to AABB collision test.
it would be cool to have an overload of the HitTest method that returns the index of the hit bar too. Maybe as a separate interface, like IHittablePlot
interface IHittablePlot : IHittable
{
bool HitTest(Coordinate coord, out int hitElementIndex);
}
Code example:
Issue Analytics
- State:
- Created a year ago
- Comments:8 (4 by maintainers)
Top GitHub Comments
It works perfect:
@swharden Yes sure! I just posted my code so it can be useful for someone else. But I did’t imagine you would finish adding the feature so quickly. Thanks for everything. At the moment I will use my solution for this chart, but I still need to add a lot of more charts to the application so I’m pretty sure I will use the new ´BarSeries´.
Thank you!
Edit: I saw you already made a release, amazing! Thanks!