Legend Series Order

TeeChart for ActiveX, COM and ASP
Post Reply
LAL
Newbie
Newbie
Posts: 40
Joined: Fri Jun 20, 2008 12:00 am

Legend Series Order

Post by LAL » Wed Aug 20, 2008 4:13 am

I have added my series in a particular order so that they draw correctly, however that isn't the order I'd like them to display in the chart legend.

So is it possible to control the series order in the legend without changing the order of th series themselves?

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

Post by Yeray » Wed Aug 20, 2008 8:22 am

Hi LVL,

I'm afraid that the feature you doesn't exist. But there are others that you may haven't seen such as OnGetLegendText and OnLegendDrawSymbol events. And also...

You can hide a series to be shown:

Code: Select all

TChart1.Series(0).ShowInLegend = False
Or you could simply invert the legend items order:

Code: Select all

TChart1.Legend.Inverted = True
Finally, you always could customize your legend at maximum drawing directly to the canvas what you want.
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

LAL
Newbie
Newbie
Posts: 40
Joined: Fri Jun 20, 2008 12:00 am

Post by LAL » Thu Aug 21, 2008 8:46 pm

Yeray,

Thanks for the reply...I actually worked around this using a combination of hiding series from the legend and adding dummy series just for the legend.

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

Post by Yeray » Fri Aug 22, 2008 8:23 am

Hi,

Here is a portion of code showing how you could draw a custom legend directly to the canvas. Only to show how you could also do it.

Code: Select all

Private Sub TChart1_OnAfterDraw()
  With TChart1.Canvas
    'legend rect
    .Rectangle TChart1.ChartBounds.Right - 85, 100, TChart1.ChartBounds.Right - 15, 200
    
    'series 1
    .Brush.Color = TChart1.Series(0).Color
    .Rectangle TChart1.ChartBounds.Right - 80, 107, TChart1.ChartBounds.Right - 70, 117
    .Brush.Color = vbWhite
    .TextOut TChart1.ChartBounds.Right - 65, 105, "Series 1"
    
    'series 2
    '...
  End With
End Sub
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