08-12-2010 06:16 AM
Hi All,
I have an application that reads a data from Network Analyzer using Visual Studio .NET,C# to the ScatterGraph where 4 XYCursor on it.
Like a Network Analyzer cursors behaves, I want to to LOCK the Cursor to the X-Axis on a fixed frequency dragging with a mouse, while the Y data maybe changing/updating. I have tried all the possibilities; SnapMode.ToPlot,SnapMode.Floating,SnapMode.Fixed,SnapMode.NeasrestPoint.
What I have expected from cursors is when I set the SnapMode.ToPlot, it remains there upto someone moves to the new position. But in SnapMode.ToPlot mode it moves bask and forth along with xAxis.
Is there a way to fix a cursor at some point on X-Axis, remains there upto when someone changes by moving right or left, and refreshes the Y-values as it changes.
Currently, the cursor "moves/floats" around while the live data updates and mode is SnapMode.ToPlot
Regards
Cengiz EKEN
Solved! Go to Solution.
08-13-2010 05:13 AM - edited 08-13-2010 05:13 AM
Hi there,
You can use the XYCursor.XPosition to move the cursor.
The cursors always point to a data point on the plot area in the SnapMode.ToPlot.
Use the XYCursor.XPosition to fix the cursor at a know location (lets say at 5 on the x-axis) on the x-axis. But if the data that you plotted does not have a value (i.e. the xData that is being plotted does not have the value 5) then the cursor would try to snap itself to the plot and hence it would not stay at the specified value (i.e. 5).
Here is what I would do
//Here the SnapMode is ToPlot.
double myPosition = 5; //initial default position
private void PlotMayData(object sender, EventArgs e)
{
// Get the data
double[] xData = GetXData();
double[] yData = GetYData();
// Plot the data
scatterGraph1.PlotXY(xData, yData);
// Set same x-position for our cursor,
// so that it does not move back and forth while plotting.
xyCursor1.XPosition = myPosition;
}
private void xyCursor1_AfterMove(object sender, AfterMoveXYCursorEventArgs e)
{
if (e.Action == NationalInstruments.UI.Action.ByMouse)
{
// Whenever the user moves the cursor with mouse,
// change 'myPosition' variable.
myPosition = xyCursor1.XPosition;
}
}
However, if I use WaveformGraph to plot the data in the above code and set the cursor position (to 5). The cursor always stays at my value of interest (i.e. 5) on the x-axis. I do not need to worry about what data I am plotting.
Hope this helps.
If you wanted something else, please attach a sample code so that we could help you effectively.
Vijet Patankar
National Instruments.
08-13-2010 09:17 AM
Hi Vijet,
I have been working on that for 2 days.That is what I want. Thanks a lot. Infact I have tried the AfterMoved event but I don't know the "NationalInstruments.UI.Action.ByMouse" action. Thanks for your great help.
Regsard