LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to control the expansion direction of a XY Graph legend

Solved!
Go to solution

Hello,

 

I am adjusting the number of plots using the "Legend.Number of Rows(LegNumRows)" property node of a XY graph. I would like the legend to expand in the horizontal direction (to the right). I can choose the expansion/growth direction of the legend on the front panel using the scale dot on the right edge of the legend, similar to an array. So far so good. But problem arises when the number of plots(LegNumRows) property drops to 1 or 0. What I mean is this: Say I have 3 plots on the legend arranged in the horizontal direction. I run the application. Then I reduce the number of plots programatically (using LegNumRows property node) to 1. Finally I increase the number of the plots again to 3. This time the legend expands/grows in the vertical direction. But I want it to stay in the horizontal direction.

 

Is there any way to do this?

 

As a side note, I found out that the legend is actually an array of clusters. I found it out by first customizing the XY graph, then customizing the legend. But still no luck. Is there a way of programatically alter the inner objects of a control in the run-time?

 

I am curious to know if there is any elegant programmatical solution to this problem. I appreciate any help or idea.

 

Thanks.

 

Burak Soysal


Burak Soysal

Acrome Robotik Sistemleri
İTÜ Ayazağa Kampüsü Koruyolu ARI4 Binası No:B204 34469 Maslak İstanbul
Download All
0 Kudos
Message 1 of 6
(3,581 Views)

I guess the only elegant solution is one that you've almost pieced together yourself. You already figured out that the legends is an array of clusters, so one of your options could be to create your own identicaly cluster and handle the case that the legend is set to 1 or 0. What this would do is keep your legend size above 2 always, so it will expand the direction you want.

Logic like this (just fit thisin to your LV code where needed):

 

If NewLegendSize == 0
           Hide Legend
           Hide all plots on graph
ElseIf NewLegendSize == 1
           Hide Legend
           Hide extra plots except for 1
           Set value of SingleLegend (your custom cluster)
           Show SingleLegend
Else
           LegendSize = NewLegendSize

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 2 of 6
(3,542 Views)

Hello James, thank you very much for your answer. Your solution is very nice but my problem with that approach is that, for the single plot case I have to use my own array. But in that case I lose some functionality, namely the menu for plot properties that pops up when clicked on the plot legend. It has some nice functionality such as changing plot color, thickness, style etc. Do you have any idea how I can keep that functionality - other than writing it from scratch, I am too reluctant for that 🙂


Burak Soysal

Acrome Robotik Sistemleri
İTÜ Ayazağa Kampüsü Koruyolu ARI4 Binası No:B204 34469 Maslak İstanbul
0 Kudos
Message 3 of 6
(3,531 Views)
Solution
Accepted by topic author b.soysal

You can create a custom control and replace the control with your own image that matches the background. Then place this control over the extra legend item(s) to hide it. This is a little tricky to describe so I made you  an example:

I Am Legend.PNG

When run, the legend cover blends in with the background and the legend.

 

I made a boolean, then went to Advanced > Customize. I then copied a screenshot section that I took of the edge of a legend in to replace the normal boolean picture. Placing this boolean just right, you can cover up one end of the legend and if you disable the boolean the user won't be able to click it. When you need more or less than 1 legend element, you can hide the boolean programmatically.

It takes some finagling with the picture (I used paint), but I bet you can get it just right if you spend some time on it.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


Message 4 of 6
(3,480 Views)

James, that's a wonderful solution, and very interesting way of thinking. I could have never thought of that.

 

The attached vi has a very cool name for a vi, by the way 🙂

 

Thanks a lot.


Burak Soysal

Acrome Robotik Sistemleri
İTÜ Ayazağa Kampüsü Koruyolu ARI4 Binası No:B204 34469 Maslak İstanbul
0 Kudos
Message 5 of 6
(3,471 Views)

No problem! I just realized you will need to handle the zero case as well since you can't set legend size to zero. So in that case, hide the legend and hide the boolean. This should mean your legend size never gets set below 2.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 6 of 6
(3,460 Views)