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: 

Interactively displaying Scatter Graph XY point values

I'd like to display the X-Y values in a pop-up window, when the user hovers the cursor over a point on the graph.
Can someone suggest a general method for doing this?
Thanks in advance for the help,
Dennis
0 Kudos
Message 1 of 6
(3,870 Views)
If you want to display tooltips and you have Measurement Studio 7.1, you can do this by setting the ScatterGraph.ToolTipsEnabled to true. This will display a tooltip with the x and y data coordinate of the point when you hover the mouse over the point. You can customize the formatting of the x and y values via the ToolTipXFormat and ToolTipYFormat properties.

If you want to display a popup, you can handle the graph's PlotAreaMouseDown event, pass the X/Y property values of the event arguments to the graph's GetPlotAt method, and if the method returns a non-null reference, the mouse is over a data point. You can pass out parameters to the GetPlotAt method to receive the corresponding x and y data values. You could then format these values to display the coordinates in a popup. For example:


private void OnGraphPlotAreaMouseDown(object sender, MouseEventArgs e)
{
double xData, yData;
XYPlot plot = scatterGraph1.GetPlotAt(e.X, e.Y, out xData, out yData);

if (plot != null)
{
string message = String.Format("X: {0}, Y: {1}", xData, yData);
MessageBox.Show(message);
}
}


- Elton
0 Kudos
Message 2 of 6
(3,869 Views)
Hello Elton,
Thanks a lot for your help.
I'm currently using MS V7.0. Was the ToolTipsEnabled property you mentioned added in V7.1?

Best regards,
Dennis
0 Kudos
Message 3 of 6
(3,864 Views)
Hello Elton,

Was the GetPlotAt() method added in V7.1? In my version (V7.0), it does not appear to be a public or protected method of ScatterGraph.

Thanks again for your help,
Dennis
0 Kudos
Message 4 of 6
(3,859 Views)
The ToolTipsEnabled property and GetPlotAt method were new members that were added in Measurement Studio 7.1.

- Elton
0 Kudos
Message 5 of 6
(3,857 Views)
Hello Elton,
Thanks a lot. I'll upgrade.
Dennis
0 Kudos
Message 6 of 6
(3,854 Views)