LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Graph - How to keep "Legend:Number of Rows Property" always horizontal?

Solved!
Go to solution

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?

 

Fig. 1 - Original graphFig. 1 - Original graph

 

Fig. 2 - When the number of rows goes to 3 or more, the legend grows horizontally (right behavior)Fig. 2 - When the number of rows goes to 3 or more, the legend grows horizontally (right behavior)

 

Fig. 3 - If the number of rows goes to 1, then the legend increment vertically (wrong behavior)Fig. 3 - If the number of rows goes to 1, then the legend increment vertically (wrong behavior)

 

Fig. 4 - VI snippetFig. 4 - VI snippet

 

Obs.: The number of plots can change with the application running, so I need to programmatically make the "rows" in the legend increment horizontally

0 Kudos
Message 1 of 10
(2,593 Views)

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.

"If you weren't supposed to push it, it wouldn't be a button."
Message 2 of 10
(2,571 Views)

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:

XY Graph.png

 

The project also contains the script to re-create the legend reference:

Script Create Plot Legend Reference.png

Finally, I tested in an executable and it works.

Message 3 of 10
(2,549 Views)

Here is a more generic thingy.

"If you weren't supposed to push it, it wouldn't be a button."
Message 4 of 10
(2,489 Views)

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.

"If you weren't supposed to push it, it wouldn't be a button."
Message 5 of 10
(2,451 Views)

@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 ?

Message 6 of 10
(2,421 Views)
Solution
Accepted by topic author mthheitor

@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"

"If you weren't supposed to push it, it wouldn't be a button."
Message 7 of 10
(2,358 Views)

Slightly improved version.

"If you weren't supposed to push it, it wouldn't be a button."
Message 8 of 10
(2,349 Views)

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)

0 Kudos
Message 9 of 10
(2,284 Views)

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.

Message 10 of 10
(2,224 Views)