12-07-2022 02:32 PM
Hello,
I'm trying to build a XY Graph with multiple plots (Fig. 1).
If the graph have 2 plots and I change the property "Legend:Number of Rows Property" to 3 or more, the legend grows in the horizontal (Fig. 2 - right behavior)
But if the plots goes to 1, then goes to 2 or more, the legend grows in the vertical (Fig. 3 - wrong behavior)
How can I change the "Legend:Number of Rows Property" and make the legend be always horizontal?
Obs.: The number of plots can change with the application running, so I need to programmatically make the "rows" in the legend increment horizontally
Solved! Go to Solution.
12-07-2022 03:55 PM
Sorry, I couldn't find a solution.
I did discover that inside the legend is an array; and it has properties of "Number of Rows" and "Number of Columns".
I could manipulate the number of columns down to 1, then back up and get the desired effect; however I could not find any way to programmatially get access to that array.
12-07-2022 04:57 PM
It seems NI did not anticipate this use case.
They could have provided another property like "Legend:Number of Columns", but they didn't...
I found a way to create a static reference to the legend array via scripting, then use this reference in the VI to manipulate the number of columns:
The project also contains the script to re-create the legend reference:
Finally, I tested in an executable and it works.
12-08-2022 09:54 AM
Here is a more generic thingy.
12-08-2022 02:35 PM
And after all that, it turns out that all you really have to do is right-click on the legend and select: Create → Property Node.
12-08-2022 05:02 PM
@paul_cardinale wrote:
And after all that, it turns out that all you really have to do is right-click on the legend and select: Create → Property Node.
I don't have the menu item "Create" when right-clicking on the legend, do you have a plugin for that ?
12-09-2022 07:35 AM
@raphschru wrote:
@paul_cardinale wrote:
And after all that, it turns out that all you really have to do is right-click on the legend and select: Create → Property Node.
I don't have the menu item "Create" when right-clicking on the legend, do you have a plugin for that ?
Add this line to labview.ini:
AdvancedPlotLegendMenu="True"
12-09-2022 10:21 AM
Slightly improved version.
12-10-2022 11:30 AM - edited 12-10-2022 11:31 AM
Thanks everyone for posting in this topic. All answers were new learning to me
@paul_cardinale
• Add AdvancedPlotLegendMenu="True" to labview.ini works like a charm. Thank you
• Your Create Reference-Prop_Node-Invk_Node of Sub-Objects in a Control.vi is great. The 1st version was a little confused, but the 2nd is fantastic. New options for our LabVIEW "toolbox" 🙂
@raphschru
• Your scripting .vi is cool, but I think @paul_cardinale idea is more simple. I tried to run your vi files and couldn't (version =/= 2020).
I saw the .png files in the .zip file, but can you post the .vi files in LabVIEW 2012? (this way more users can use your idea in a easier way)
12-11-2022 04:03 PM
My scripting VI was a proof of concept for creating a reference to a normally not-accessible subcontrol.
Then paul_cardinale turned it into a more usable tool.
Now you can access almost any sub-part of a composite control like the plot/scale/cursor legends of a Graph control, the browse button of a Path control, the button of a Timestamp control, etc...
As for the ini key, it is simpler but limited to the plot legend and the scale legend of Graph controls.