Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

Scattergraph MoveCursor method not behaving as expected

Solved!
Go to solution

I am trying to do something very simple: basically keep the cursor on the latest point being plotted while trying to draw multiple scatterplots. Here is a snippet of the code where I set the cursor properties:

 

********************************************************************************************************************************************************************************

internal NationalInstruments.UI.WindowsForms.ScatterGraph sgImpedance;

private List<clsZofFDataType> m_ZDataPlots = new List<clsZofFDataType>(); //clsZofFDataType is a class representing the data contained in a plot. 

... // more code follows here

...

 

 

sgImpedance.Cursors[0].Plot = sgImpedance.Plots[m_ZDataPlots.Count - 1]; //sgImpedance is a scattergraph as initialized above
sgImpedance.Cursors[0].Color = newColor; 
sgImpedance.Cursors[0].SnapMode = CursorSnapMode.NearestPoint;


if (sgImpedance.Plots[m_ZDataPlots.Count - 1].HistoryCount > 1)
   sgImpedance.Cursors[0].MoveCursor(sgImpedance.Plots[m_ZDataPlots.Count - 1].HistoryCount - 1);
else
   sgImpedance.Cursors[0].MoveCursor(0);

 

********************************************************************************************************************************************************************************

 

The cursor however keeps staying at the centre of the plot; it is on the correct plot but it is never at the last plotted point. Is there any attribute that I need to set, or some event that needs to be raised in order for the cursor to stay on the current point being plotted? I attached a screen capture to show what's going on. 

 

Any help will be appreciated. If I need to elaborate more, please let me know. Thank a lot!

0 Kudos
Message 1 of 7
(6,104 Views)

It looks like you are using the method properly, however, I would recommend displaying the data at the point that you are trying to set the cursor at to confirm that you are referencing the right point.

Also, when do you call the MoveCursor method? Is it in a loop of some kind when you update the graph?

Regards,

Anjelica W.
National Instruments
Product Marketing Manager
FlexLogger and TestStand
0 Kudos
Message 2 of 7
(6,067 Views)

Hi, we are referencing the right point, as determined by a Debug Console output (screenshot attached: console2.png). But the cursor keeps moving to the central point. Hardcoding the index as a parameter for the MoveCursor method hasn't been helping either. 

 

Also, we aren't calling the MoveCursor method from any loop. We acquire the data in the x_Data, y_Data arrays and just reference the last point for the cursor to move to. 

Download All
0 Kudos
Message 3 of 7
(6,048 Views)

Does the cursor stop moving after a certain time or does it stay in the same spot from the start? I believe that the MoveCursor method will move the cursor everytime it is called. If you only call it once, then the cursor will remain in the same place.

Regards,

Anjelica W.
National Instruments
Product Marketing Manager
FlexLogger and TestStand
0 Kudos
Message 4 of 7
(6,024 Views)

NO the cursor doesn't stop moving, it moves everytime we call it after adding new data to our arrays, but only moves so that it stays centred instead of moving to the latest point plotted.

 

 

 

Thanks for looking into this.

 

0 Kudos
Message 5 of 7
(6,021 Views)
Solution
Accepted by sharmishtha

Can you provide some sample code so I can reproduce the behavior on my end?

Regards,

Anjelica W.
National Instruments
Product Marketing Manager
FlexLogger and TestStand
0 Kudos
Message 6 of 7
(5,996 Views)

Hello, just wanted to let you know that we've actually solved the issue. We realized that there was another part of the code that was overriding the MoveCursor method that should have updated the cursor the way we wanted to. So we have taken care of that and it works fine now. Thanks again for all your help. 

0 Kudos
Message 7 of 7
(5,976 Views)