Page 1 of 1

Getting the current YAxisSegment on mouse move

Posted: Mon Dec 25, 2023 8:48 am
by aelbuz
Hi,

Is it possible to get the current YAxisSegment or segment index on chart mouse move event or somewhere?

I have multiple segmented Y axes with 1 point series each and have only one annotation (not for each series or Y axes) in the chart. So I need to find the segment the mouse is over and show the annotation for this point series' point.

I may calculate and find the current mouse over segment with _chart.ViewXY.GetGraphSegmentInfo() parameters but is there a better or easy way to find this?

Thanks.

Re: Getting the current YAxisSegment on mouse move

Posted: Mon Dec 25, 2023 11:31 am
by ArctionKestutis
Yes, this approach is good, especially if you want to find segment index.
An alternative to _chart.ViewXY.GetGraphSegmentInfo() method/usage is yAxis.GetGraphSegmentTopAndHeight() method.
With both methods you will get yAxis/segment size in screen pixels(PX). And don't forget that in WPF mouse position is estimated in DIPs. Therefore, you need to do conversion between those units (e.g. with LightningChart class DpiHelper).

All the best.

Re: Getting the current YAxisSegment on mouse move

Posted: Mon Dec 25, 2023 1:53 pm
by aelbuz
Great, thank you!