LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

updating a single plot

Hi,
 
I have an XY graph with four plots. Three of these plots are related and the fourth is a circle around them. The circle's diameter is controlled by a control on the front panel. I want the XY graph to update whenever that value is changed, so I have used an event structure. I have not posted my code because this is all part of a much larger program so my vi would potentially make no sense. The problem I am having is that I need to update the circle (an array of points) without changing whatever values are being displayed in the other plots. How do I keep 3/4 of the plots with their current value while changing the 4th plot?
 
Any assistance would be appreciated, thank you in advance.
Jeff


Using Labview 7 Express
0 Kudos
Message 1 of 8
(2,782 Views)
Your 4 plots are contained in an array, right? Each element is one of the plots, so you could just use Replace array subset to replace the circle plot with a new one and leave the other plots unchanged. The tricky part is bundling the plot together because an XY graph is an array of clusters, and each cluster contains an array of clusters. If you got to the point where you had a 4 plot graph, I'm sure you know how that all works, though.
Message 2 of 8
(2,771 Views)
Thank you for the reply. I dont have a single array that represents the values on the xy chart, There are a number of arrays in different places of the vi that are passed into local variables representing the chart depending on user interaction with the program (I have a large event structure). So it is impossible for me to simply replace one of the arrays while it is passed into the xy chart, although I agree that would normally be the easiest way. Whenever I am changing the value of the chart, I bundle 4 clusters (each is a cluster of two doubles) into a cluster array, which i send into the xy chart. So, I tried to do something where I created a local variable and used it to read the array of clusters currently being displayed on the chart, and then unbundled this into its seperate clusters (I would then replace the relevant cluster). However, for some reason the array of clusters being read from the chart only has a size of 1 (instead of the expected size of 4), so obviously it is impossible for me to replace the relevant subset. I had thought of the possibility where I could create 3 seperate indicators, and each one would represent the current value of each of the elements in the cluster array (except for the element that is going to be replaced (the circle)), but this is a very messy way of doing it, and I believe that there must be a more efficient way of doing this, since it would be impossibly messy if I had any more plots!
 
Does anyone know a more efficient way to do this?
Jeff


Using Labview 7 Express
0 Kudos
Message 3 of 8
(2,768 Views)
I would do it with a shift register that holds the array of data going to the graph. This way you can do what I said and replace one element of the array, then pass it to the graph. In each event case that changes on of the plots, just replace that one element and update the graph with a local variable write. This is more efficient than constantly reading local variables, and more readable in my opinion.
0 Kudos
Message 4 of 8
(2,763 Views)
I agree that a shift register would be more readable than local variables, but I am not sure it would work in my case. To give you a more complete picture of the section of my code that is relevant. There are two parallel while loops that affect this xy chart. They cannot be combined since one needs to execute much faster than the other. One while loops is used mainly to control a number of radio buttons, depending on which button is pressed, the chart will show completely different data, there are a total of 4 places the xy chart can be changed in this while loop, however they are in parallel in a case structure, so they could be controlled with a shift register. The other while loop contains an event structure that in turn contains the main program, and the final result of the program outputs to the xy chart. There are two seperate events that can change values displayed on the xy chart: one is by changing the numeric control for the diameter of the circle, and the other occurs when the main program is complete, all the values on the xy are updated. I understand how to use a shift register if the chart was only being updated in a single while loop, but I dont believe that solution can be implemented with parallel while loops, for the reason that the shift registers would be carrying different values forward. As a worst case solution, I could try to seperate the circle plot from the others, and have a local variable that remembers all three of the others, but like you said, this is not very readable.
Jeff


Using Labview 7 Express
0 Kudos
Message 5 of 8
(2,755 Views)

Well in this case you might be stuck with local variables unless you wanted to use something like a queue to store the plots. When you create a local variable of the graph, it should be an array. Now what you have to do is read the local variable, replace an element with a new cluster representing the plot, and output this array to another local variable of the graph. You're essentially doing the same thing as the shift register idea I described, but with local variables.

This is what I'm talking about:

Message Edited by Marc A on 03-13-2007 03:27 PM

Message 6 of 8
(2,749 Views)
very weird, that was actually the first thing I tried to do, and it told me that the cluster I was trying to replace with was invalid, but at your suggestion I tried it again, and it worked. Thank you!
Jeff


Using Labview 7 Express
0 Kudos
Message 7 of 8
(2,744 Views)
Multiplot XY graphs are quite confusing with all the clusters and arrays. You might have just forgot to bundle something previously. I'm glad you got it working now.
0 Kudos
Message 8 of 8
(2,736 Views)