LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Move data left and right on graph realtime

Solved!
Go to solution

I have an X 1D array and a Y 1D array for the XY Graph.

I want to move the graph along the x-axis. I want it to act as if I am grabbing the plotted values and moving them.

The easiest way I thought would be to add a slider value to each of the X 1D array elements. The value keeps adding when I move the slider is positive and subtracting when the slider is negative. I want the graph to move left or right as the slider moves.

Any ideas?

Thanks!

CLD Certified 2014
0 Kudos
Message 1 of 7
(4,194 Views)

Here is an example I cooked up.

CLD Certified 2014
0 Kudos
Message 2 of 7
(4,192 Views)

Greetings ADrexelDragon.

 

You were definitely on the right track with your example.  While this isn't something that my group normally does, I was fascinated by the problem and did a little work with your code.  My modifications to your example are far from perfect / clean but I think it may be closer to the exact behavior you are in search for.  Below is a summary of some of the modifications I made.

 

  • Set a timeout on the event structure to allow the Stop button to function correctly
  • Used the timeout case and a First Call primitive to set the initial state of the graphs
  • Fixed the x-axis / turned autoscale off
  • The value of the slider is added to the Xdata but now the previous value of the slider is subtracted so that only the change since the last update is applied
  • Value Changed case no longer updates the arrays for the graphs, just the graph
  • Arrays for the plots are only updated on mouse up  

The last two bullet points handle the fact that when moving the slider quickly, the value changed event is not triggered quickly enough to truly update the data for the plots in "real time". 

 

I hope these modifications help.  Let me know if you have any questions. 

 

(Saved in LabVIEW 2010 SP1)

 

Michael G.
Applications Engineer
National Instruments
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Self-realization: I was thinking of the immortal words of Socrates, who said, "... I drank what?"
Message 3 of 7
(4,173 Views)

Hey Michael G.

Thanks for the response and example! It has displayed what I am trying to. That being said, I am now trying to have the plots stay in their "slid" position; therefore, I can align more than one at a time. With your example the plots are reverted to the origional on the movement of a different slider. I will use your code and work from there.

Thank you,

Nick

CLD Certified 2014
0 Kudos
Message 4 of 7
(4,167 Views)

I stand corrected. The vi is now working fine. Thank you for your help.

CLD Certified 2014
0 Kudos
Message 5 of 7
(4,157 Views)

Michael G.

For some reason the vi has gone back to reverting to the origional plots when I switch sliders. Do you know why this happens? I can't seem to find where it does that. It only happens the first time the vi is loaded. I click the stop button and re-run it and it works fine. The issue only occurs when the vi is run the first time.

Thanks,

Nick

CLD Certified 2014
0 Kudos
Message 6 of 7
(4,137 Views)
Solution
Accepted by topic author ADrexelDragon

Michael,

Here is what I found works. It is a lot simpler than what you suggested but there may be some errors that could arise due to immproper programming. I am not sure.

 

CLD Certified 2014
Download All
0 Kudos
Message 7 of 7
(4,111 Views)