ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting nearest plot

I have multiple plots on a scattergraph.  The user wants to click on one of those plots and have the cursor be assigned to that plot.
 
Is there a way to do this?  I can't find anything that will work.
 
VS2005
NI 7.1
C#
 
thanks,
Scott
0 Kudos
Message 1 of 5
(4,412 Views)

The graphs have a GetPlotAt method that will return a reference to the plot if there is a plot point at the specified coordinates. You could use this method in a mouse event handler, check to see if there is a plot at the specified coordinates, and if so, associate the plot with the cursor. For example:

private void OnPlotAreaMouseDown(object sender, MouseEventArgs e)
{
    XYPlot plot = graph.GetPlotAt(e.X, e.Y);
    if (plot != null)
        xyCursor1.Plot = plot;
}

- Elton

0 Kudos
Message 2 of 5
(4,406 Views)

Thanks Elton.   That will work fine.  I was hoping there was a "get nearest plot" type of thing.  But we will just have to make the user click on the plot.

 

Thanks again,

Scott

0 Kudos
Message 3 of 5
(4,398 Views)

Another thing you could consider doing is adding a legend for the plots and then let users associate the cursor with the plots via the legend items, via clicking on the legend item for the plot, a context menu on the legend, etc.

- Elton

0 Kudos
Message 4 of 5
(4,392 Views)

Yes.  That was in fact one of the ways I had suggested.  They want the "click on plot" method also, however, because that is what their previous Motif program gave them.  I will also give them the up down arrow keys to cycle through plots.

 

Scott

Message 5 of 5
(4,388 Views)