DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Resize Legend Area in View - variable or command to do this?

Solved!
Go to solution

Hi,

Is there a variable or command to adjust the width of the legend area in View?

I have plots in View, but the legend is mainly hidden - only the colours show.  Manually, I can resize the legend area to expose all the legend info.  Can this be done by script?  Any help is appreciated.

Thanks!

LegendArea.PNG

 

0 Kudos
Message 1 of 7
(3,614 Views)

Hi mrme

 

There is an API for VIEW. In this help topic you find an example to change the legend width:

http://zone.ni.com/reference/en-XX/help/370858M-01/scriptview/properties/view_property_legendwidth_i...

Hope this helps.

Winfried

0 Kudos
Message 2 of 7
(3,597 Views)

Hi Winfried,

Thanks for the reply.  However, changing the legend width does not help.  True, the actual legend width is increased, but it remains 'hidden'.  It is why I thought that I should change the legend area width...just that I am not able to do it via a script..

By the way, I forgot to say that I have Diadem 2012.

Thanks again.

Best regards

0 Kudos
Message 3 of 7
(3,571 Views)

If your legend does not have any column you can add them via script (following the example in winner's link)

 

Dim MyChart
View.ActiveSheet.ActiveArea.DisplayObjType = "CurveChart2D"
Set MyChart = View.ActiveSheet.ActiveArea.DisplayObj
MyChart.LegendWidth = 100
MyChart.LegendItems.add("Name")
MyChart.LegendItems.add("Description")
MyChart.LegendItems.add("unit_string")
'...

and so on.

0 Kudos
Message 4 of 7
(3,555 Views)

Hi tlahoz,

 

Thanks for the feedback.  The legend has columns.  But, these columns are hidden.  I have changed the width, added and removed fields, with no success.  The legend changes as expected, but by default, the area allocated to it seems to be too small.  The legend area does not change automatically to accommodate the width of the legend.  I can do this manually to expose the full legend.

 Legend2.PNG

The plots are created by a script and I would like to replace the manual adjustment of the legend area by a command if possible.

Thanks for the support.

0 Kudos
Message 5 of 7
(3,542 Views)
Solution
Accepted by topic author mrme

Hi mrme,

 

Have you tried modifying the value of "LegendWidth" to something besides 100?  I just tried the example script posted above with 70 vs 250 and saw that width change by ~3.5 times as much -- perhaps the example just doesn't set it long enough for your particular text?

 

Before:

before.png

 

After (70):

at legendwidth = 70.png

 

After (250):

at legendwidth =250.png

Highest Regards,

Paul
0 Kudos
Message 6 of 7
(3,510 Views)
Solution
Accepted by topic author mrme

Hi Paul,

 

Yes - Legendwidth works.  I must admit that I had made an embarrassing mistake in my previous efforts - my script was not selecting the correct worksheet (was modifying another sheet instead). 

Thanks also to 'winner' and 'tlahoz' for their support.

 

 

0 Kudos
Message 7 of 7
(3,490 Views)