From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get X-axis location from mouse click location on waveformgraph

Solved!
Go to solution

Hi,

    I'm trying to place cursor using context menu on zoomed graph.

    So, I need to get x location from mouse click location. I searched for it but didn't get proper method for it.    

0 Kudos
Message 1 of 3
(2,458 Views)
Solution
Accepted by topic author akshykhade

var plotRect = waveformgraph.PlotAreaBounds;

var xRange = waveformgraph.XAxes[0].Range.Maximum - waveformgraph.XAxes[0].Range.Minimum;

var factor = plotRect.Width / xRange;

waveformgraph.Cursors[0].XPosition = waveformgraph.XAxes[0].Range.Minimum + ((clickLocation.X - PlotAreaBounds.X) / factor);

0 Kudos
Message 2 of 3
(2,408 Views)

Thanks for your solution.

0 Kudos
Message 3 of 3
(2,378 Views)