01-03-2017 04:17 AM
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!
Solved! Go to Solution.
01-03-2017 04:37 AM
Hi mrme
There is an API for VIEW. In this help topic you find an example to change the legend width:
Hope this helps.
Winfried
01-03-2017 06:03 AM
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
01-03-2017 10:00 AM
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.
01-04-2017 01:51 AM - edited 01-04-2017 02:14 AM
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.
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.
01-05-2017 12:39 PM - edited 01-05-2017 12:40 PM
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:
After (70):
After (250):
01-06-2017 06:08 AM
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.