Getting the current YAxisSegment on mouse move

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
aelbuz
Posts: 12
Joined: Fri Sep 15, 2023 1:56 pm

Getting the current YAxisSegment on mouse move

Post by aelbuz » Mon Dec 25, 2023 8:48 am

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.

ArctionKestutis
Posts: 555
Joined: Mon Mar 14, 2016 9:22 am

Re: Getting the current YAxisSegment on mouse move

Post by ArctionKestutis » Mon Dec 25, 2023 11:31 am

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.

aelbuz
Posts: 12
Joined: Fri Sep 15, 2023 1:56 pm

Re: Getting the current YAxisSegment on mouse move

Post by aelbuz » Mon Dec 25, 2023 1:53 pm

Great, thank you!

Post Reply