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.

Implement IHittable for BarPlot

See original GitHub issue

Feature 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.

image

The problem arises with bar plots. Since there is no MouseOver method, or any way to detect collisions with the figure:

image

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:

  1. Inside the draw method store in a private variable the position and size of each bar.
  2. 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:closed
  • Created a year ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
jhm-cibermancommented, Jun 21, 2022

It works perfect:

Animation

0reactions
jhm-cibermancommented, Jun 22, 2022

@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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Plottable: IHittable · Issue #1844 · ScottPlot ...
Implementing full-fledged event generation capabilities for each Plottable is labor-intensive and will significantly increase their code base.
Read more >
How to Create a Bar Plot in Python: A Step-by-Step Guide ...
This tutorial will teach us to implement and understand a bar plot in Python. Learning Objectives. In this tutorial, you will learn about ......
Read more >
Bar Plot in Matplotlib
A bar plot or bar chart is a graph that represents the category of data with rectangular bars with lengths and heights that...
Read more >
How can I add features or dimensions to my bar plot? | R FAQ
This page will show how to build up from the basic bar plot in R, adding another categorical separation to the ... Again...
Read more >
Chapter 8 Bar Graph | Basic R Guide for NSC Statistics
To draw a bar graph, use the function, barplot(height = quantitative_variable). Note that we want the height of the bar graph to follow...
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