Page 1 of 1

Customizing the Legend

Posted: Wed Apr 07, 2004 5:18 pm
by 9336214
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

Posted: Wed Apr 14, 2004 12:17 pm
by Marjan
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.

Posted: Tue Apr 12, 2005 9:53 pm
by 9338026
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.