From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-04-2009 05:59 PM
Ok, this is annoying me now.
I have a waveform graph in my current application. I use a lot of programmatic control to get it to adapt and display just the way I like it on the front panel (the application is meant to very customisable for the user). The waveform graph displays any number of plots from 1 to 12 simultaneously, and automatically adapts sensible things like axes labels and legend size to show those plots I want to show.
Now. I don't want the user to be able to edit the name of the plots in the Legend. However, if I use the Disable Legend property, this disables the whole legend resulting in the user not being able to change the plot style/colour/symbols etc. As I need to keep this level of customisation I therefore need to keep the legend enabled, but somehow prevent them from being able to change the plot name.
I can't detect plot name changes programmatically, so I can't restore them if the user makes any changes. Therefore I'm stuck.
Any ideas anyone
Solved! Go to Solution.
06-04-2009 08:36 PM - edited 06-04-2009 08:39 PM
What you can do is place a decoration box over the name part of the legend. Of course that would hide the names. But if you use the paint brush and color picker and select it for Transparent and paing the decoration, now it will be invisible and you can see through it. When running, any cursor action will be acting on the decoration rather than the legend names preventing a person from interacting with it.
I'm sure there is a way to detect changes to the plot name programmatically. At the beginning of your program, you could iterate through the plots and create an array of all the names. During running, you could periodically do the same thing and compare the new array of names to the previous name. If they are different, you know you have a change and you have the previous name still stored to change it back to.
However, I would just go with the transparent box method to prevent changes.
06-04-2009 11:41 PM
You could register for a key down? event on the plot I think LabVIEW returns a reference to the subsystem (legend) of that item, and you could ignore the key down event.
Or you could write your own legend tool, the easiest is to use the normal legend and shrink the 'name' part to 0 pixels and place a table at that location.
Ton
06-05-2009 07:38 AM
Happy Friday to you all! I really enjoyed Ravens Fan's resourceful workaround... the simpliest solutions are often the best!!
I would recommend using RavenFan's workaround, but for future reference here is an example showing how to programmatically modify multi-plot names. And a link to the KB article which inspired it.
Best wishes,
How Do I Programmatically Modify the Palettes and Legends on My Graph or Chart?
http://digital.ni.com/public.nsf/allkb/A0525AF9D64408F186256BFB005970EB?OpenDocument
06-05-2009 10:08 AM
Thanks Rich,
By the way, that knowledge base article is another one of those that have image links to the ae.natinst.com website that the general public does not have access to.
See this thread for a recent conversation about this.
06-06-2009 08:22 AM
Thanks for the ideas everyone.
Ravens Fan - I would normally put a transparent box over the text, but the chart size changes with the front panel, and the legend changes size too, so I'd need to continually resize the box. I presume by box, you mean a classic decoration, so I'd have to be quite careful in returning a reference to it to allow property changes. I'm sure that possible, but I preferably need a quick solution.
TonP - I've had a play around, but all I can return is a reference to the chart within an event case, not the legend. If I refuse the key down? filter event every time, then my users won't be able to change scale ranges with the keyboard. I definitely need to check the focus object is the legend, but I can't see a way to do that. Any ideas?
Rich - Yes, I'm aware of programmatic control of charts, apologies if my opening message was not clear.
Am I the only one tired of creating lengthy workarounds to artifically construct behaviours I expect to be quite standard in LabVIEW? All I want is to stop a user changing plot names, but allow them to modify everything else
Looks like I'm going to have to start using user tags, decorations, and property nodes again...