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.
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
Extra legend
-
- Advanced
- Posts: 228
- Joined: Tue Aug 28, 2007 12:00 am
- Location: Oregon, USA
Extra legend
- Attachments
-
- Legend Custom Draw Symbol.zip
- (2.62 KiB) Downloaded 726 times
Re: Extra legend
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".
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,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
-
- Advanced
- Posts: 228
- Joined: Tue Aug 28, 2007 12:00 am
- Location: Oregon, USA
Re: Extra legend
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:
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
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
Re: Extra legend
Hi Ed,
I see in your project you've set:
However, it seems the Chart Legend TextStyle is checked instead in the sources. So this seems to work as you expected:
We'll investigate why the Chart Legend TextStyle is taken instead of the ExtraLegend's.
I see in your project you've set:
Code: Select all
FExtraLegend.Legend.TextStyle:=ltsPlain;
Code: Select all
Chart1.Legend.TextStyle:=ltsPlain;
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |