08-26-2009 03:52 PM - edited 08-26-2009 03:53 PM
smercurio is correct your vi so far has no architecture it would be best to use his program he wrote for you because it is tons more efficient than the code you are using.
08-26-2009 04:44 PM
So let me explain. The problem is not to create a graph and make some parts of it appear or disappear. It's only one part of it. The way it's done cannot be used, because the channel cannot be reloaded, it only makes appear 8 lines and and so on.
The shift register is for this, to reload each channel.The 8 lines i used is only an example, of course the original problem is not a line, it is a signal that is collected from a hardware device.
08-26-2009 05:01 PM
08-26-2009 05:12 PM - edited 08-26-2009 05:17 PM
What do you mean by "reloaded"? Are you saying that you want the on/off controls to control the visibility and the collection of data? If that's the case, then, yes, you should use a shift register. But there's still a better way to do it:
EDIT: Actually, now that I think about, instead of that hard-coded 8 you could also just use a property node to get the value of the cluster and do another Cluster to Array to get the size of it.
08-26-2009 05:26 PM
08-26-2009 05:39 PM
danilorj wrote:
The action is to clear one line that corresponds to each channel.
I'm sorry, but now you're just not making sense. Which line from "each channel"? Why would unchecking, say, channel 4 be clearing anything from the other channels?
You have not made it clear whether you're generating data all the time and just need to turn on/off certain channels, thereby not collecting the data from that channel, OR whether you're collecting the data, displaying it, and then simply allowing the user to hide/show certain channels on static data. . Your description implied that you're continuously collecting data, and that when unchecking, say, channel 4 you wanted that channel to go away. Well the second VI I wrote does that. The data is generated each time you run around the loop. It's not static. Replace the sine waveform generator with a noise generator and you will see. If you're not generating data continously, then a variant of the original VI I showed you is more appropriate.
08-26-2009 05:51 PM
OK, let me try to summarize what I understand so far. I am still not sure what you really want.
You have 8 potential channels, and you mant to be able to interactively hide/show some of the traces.
Your graph accepts a 2D array where each row corresponds to the data of one channel. All rows in a 2D array are necessarily of the same lenght, so all channels must contain the same amount of data.
From what I can tell from your code, it seems you want to built a new 2D array that only contains the selected channels. This is not a good idea, because the channels no longer always correspond to the original row indices. For example if you hide channel 5, the last row will be the 7th channel and will no longer correspond to the correct graph legend. Thus, if you go this way, you would also need to dynamically rewrite and resize the graph legend, which is a unecessary mess and distracting to the user.
The correct way is to use Saverio's technique of simply hiding the deselected data (=color it transparent) if you don't have data for the missing channels, create some dummy data (e.g. all zero). One disadvantage is the fact that the color in the legend also disappears for the hidden channels.
An alternative would be to show/hide by manipulating the data. This will only work if your data is orange (floating point, e.g. DBL or SGL). You could start out with a 8xN 2D array initialized with NaN and then replace corresponding rows with real data (size=N) for the channels you want to show.
08-26-2009 06:27 PM
08-26-2009 06:46 PM
danilorj wrote:
altenbach, could you please send me the vi with the modification you said?
The VIs are currently only virtual, and exist only in my mind. 🙂
Since I suggested several alternative modifications, let me know which one you want. It would only take a few strokes of the mouse to modify a real VI. 🙂
08-27-2009 08:33 AM