Extra legend

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Extra legend

Post by TestAlways » Wed Aug 01, 2012 1:25 am

This is my last item before I finish my app update, so I am a bit pressed to get this out.

XE2. TChart 2012.06

I am adding an extra legend via code to my chart. I want it to only have two items with custom text (unrelated to the series--they are categories of series, not series in themselves). Also, I need it to show below the current legend. I.e.

Image

It would be nice if the symbols and text were vertically aligned, but I need some margin between the two legends.

Is this possible? I have attached my demo program that produces the sample image. What needs to change?

Much appreciated,

Ed Dressel
Attachments
Legend Custom Draw Symbol.zip
(2.62 KiB) Downloaded 726 times

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

Re: Extra legend

Post by Yeray » Wed Aug 01, 2012 9:15 am

Hi Ed,

The TExtraLegendTool is probably too much linked to the regular series than what you'd need. Ie, the ShowInLegend property is shared with both legends so the only way to have a different number of items in both legends is linking a series to the TExtraLegendTool. You could create a dummy series for it, with as many values as number of items to show (and the series.Active:=false for not drawing it)

Alternatively, you could use the more flexible TCustomLegendTool. Take a look at the example at "What's New ?\Welcome !\New Chart Tools\Custom Legend" in the features demo.

In both cases you'll have to calculate the legend position manually. I'd suggest you to take a look at the "Extra Legend tool" example in the features demo. Find it at "All features\Welcome !\Tools".
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

TestAlways
Advanced
Posts: 228
Joined: Tue Aug 28, 2007 12:00 am
Location: Oregon, USA

Re: Extra legend

Post by TestAlways » Wed Aug 01, 2012 2:25 pm

Thank you... I am very close now. I created the dummy series and have it positioned where I want it--but the legend insists on showing the value. Here is a image:

Image

I added Null to the series values, but it still shows. I looked at the source code and couldn't figure it out.

I have attached the modified demo.

How can the value be removed?

(I looked at the Custom Legend demo, but when I try to view the Form, I get an "Invalid stream format" exception).

Thank you,

Ed Dressel
Attachments
Legend Custom Draw Symbol.zip
(2.98 KiB) Downloaded 686 times

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

Re: Extra legend

Post by Yeray » Thu Aug 02, 2012 11:50 am

Hi Ed,

I see in your project you've set:

Code: Select all

FExtraLegend.Legend.TextStyle:=ltsPlain;
However, it seems the Chart Legend TextStyle is checked instead in the sources. So this seems to work as you expected:

Code: Select all

Chart1.Legend.TextStyle:=ltsPlain;
We'll investigate why the Chart Legend TextStyle is taken instead of the ExtraLegend's.
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