Page 1 of 1

Size and Shape of Legend

Posted: Thu Apr 16, 2015 7:23 pm
by 9532498
I'm using TChart ActiveX version 7.0.

I want to change the size and shape of the legend. Is there a way in which I can control the number of rows and columns displayed for the legend items? For instance as I add more series to the chart, the number of items in the legend grows (more rows) and the height of the legend box increases with a corresponding decrease in the height of the chart. There is a lot of wasted space on the panel. Can I change the number of rows and columns dynamically depending on how many series I add to the chart?

Re: Size and Shape of Legend

Posted: Fri Apr 17, 2015 7:53 am
by yeray
Hello,

There are different ways to avoid the legend to increment the margin.
One of them is by setting a custom position as shown in the example at "All Features\Welcome !\Miscellaneous\Legend\Custom position":

Code: Select all

TChart1.Legend.CustomPosition = True
TChart1.Legend.Left = 123
Another option in the current version is to use MaxNumRows as shown in the example at "All Features\Welcome !\Miscellaneous\Legend\Legend max. rows":

Code: Select all

TChart1.Legend.MaxNumRows = 5
If you have several series in the chart and LegendStyle=lsAuto, or if you have LegendStyle=lsSeries, then the legend shows the series titles. Here you can avoid a series to be shown in the legend setting ShowInLegend=False. Ie:

Code: Select all

  TChart1.Aspect.View3D = False
  
  TChart1.Legend.Alignment = laBottom
  
  For i = 0 To 10
    TChart1.AddSeries scLine
    TChart1.Series(i).FillSampleValues
    
    If (i Mod 2 = 0) Then
      TChart1.Series(i).ShowInLegend = False
    End If
  Next i