Size and Shape of Legend

TeeChart for ActiveX, COM and ASP
Post Reply
nbp
Newbie
Newbie
Posts: 83
Joined: Mon Sep 18, 2006 12:00 am

Size and Shape of Legend

Post by nbp » Thu Apr 16, 2015 7:23 pm

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?

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Size and Shape of Legend

Post by Yeray » Fri Apr 17, 2015 7:53 am

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
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply