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

Crosshair snapping #701

Merged
merged 11 commits into from
Oct 27, 2022
Merged

Conversation

EniacMlezi
Copy link
Contributor

@EniacMlezi EniacMlezi commented Oct 20, 2022

Created a way for making the crosshair "snap" to the closest available ChartPoint. Can be enabled/disabled on a per axis basis

crosshair_snap.mp4

src/LiveChartsCore/Axis.cs Show resolved Hide resolved
src/LiveChartsCore/Axis.cs Outdated Show resolved Hide resolved
src/LiveChartsCore/Axis.cs Show resolved Hide resolved
@beto-rodriguez
Copy link
Owner

This looks amazing! thanks I will review it and let you know any observation.

@EniacMlezi
Copy link
Contributor Author

This looks amazing! thanks I will review it and let you know any observation.

Yes, please do! I used FindHitPoints to get the closest ChartPoint, but I bet those calculations have already been done by the ToolTip finding logic. Maybe this functionality can be hooked into that.

float crosshairX;
if (CrosshairSnapEnabled)
{
var axisIndex = Array.IndexOf(cartesianChart.XAxes, this);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only thing I don't completely like, we do not need to calculate the index, instead I think that the library should expose a read only property where we can get this value, The library internally can assign this index, there is no need to go and find it every time the crosshair is invalidated.

We can build that in a new PR, for now this seems ok.

@beto-rodriguez beto-rodriguez merged commit db16a05 into beto-rodriguez:master Oct 27, 2022
@EniacMlezi EniacMlezi deleted the CrosshairSnap branch October 28, 2022 13:15
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

Successfully merging this pull request may close these issues.

2 participants