Customizing the Legend

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Ed
Newbie
Newbie
Posts: 33
Joined: Tue Mar 09, 2004 5:00 am
Location: Oregon, USA
Contact:

Customizing the Legend

Post by Ed » Wed Apr 07, 2004 5:18 pm

I have a TPointSeries in a chart that contains other series (TMapSeries).

I add XY points to on TPointSeries and use one of 5 colors for each point in the series.

I would like the legend to not show the other series, just the TPointSeries and always have 5 items in the legend, one for each color in the TPointSeries, with text that I set. So how do I:

1) Always have 5 items in the legend?
2) Custom draw the same symbol with the correct color that the TPointSeries is using in the TChart.legend.Symbol.OnDraw event (assuming I use that event).

The TExtraLegendTool, but this doesn't allow the level of customization I want (or at least it wasn't obvious to me) and didn't have any events. Maybe I am missing the obvious?


Thanks
Ed Dresel

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Wed Apr 14, 2004 12:17 pm

Hi, Ed.

The easiest solution would be to add five "fake" series and use it only for displaying legend items. Then set all other series ShowInLegend property to false. The end result will be 5 legend items for which you can control text (series Title property), color (series Color property) and symbol (series Pointer.Style property).
Of course, you can also use chart OnGetLegend*** events to customize and manually draw legend items, but I think using the above approach is a lot simpler.
Marjan Slatinek,
http://www.steema.com

David Novo
Newbie
Newbie
Posts: 71
Joined: Fri Jul 02, 2004 4:00 am
Location: Culver City
Contact:

Post by David Novo » Tue Apr 12, 2005 9:53 pm

I have the same issue, and have been using the same solution. However, it would really be nice if you had a "custom" legend type. You already have so many events dealing with the legend. If you just added an onNeedsNumLegendItems you could probably have an entire legend under the users control.

Post Reply