Hi
I was wondering whether someone can help me with legend problem. I'm using TeeChart V6 and I want to display a pie chart with legend. My data is very simple:
Sales
Q1 100
Q2 120
Q3 150
Q4 180
I want to display this in pie chart and I want my legend to have Q1, Q2, Q3, Q4. However when I go into the "Legend" tab, the choices are :
Automatic
Series Names
Series Values
Last Value
If I pick Series Names, then the legend would displays 'Sales' which is my series name. If I pick Series Values, the legend displays 100, 120 150, 180.
Is there a way I can display the legend as Q1, Q2, Q3, Q4?
This is important for us because our client wants to be able to display their graph this way.
Thanks in advance for you help.
Vickie
How to display legend with values labels
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Hi Vickie,
You can add the text as points labels as shown in the code below. That way legend will automatically display points values and labels. If you want to only display points labels then you could also add OnGetLegendText event as shown in the example.
You can add the text as points labels as shown in the code below. That way legend will automatically display points values and labels. If you want to only display points labels then you could also add OnGetLegendText event as shown in the example.
Code: Select all
procedure TForm1.FormCreate(Sender: TObject);
begin
With Series1 do
begin
AddPie(100,'Q1');
AddPie(120,'Q2');
AddPie(150,'Q3');
AddPie(180,'Q4');
end;
end;
procedure TForm1.Chart1GetLegendText(Sender: TCustomAxisPanel;
LegendStyle: TLegendStyle; Index: Integer; var LegendText: String);
begin
LegendText:=Series1.Labels[Index];
end;
Best Regards,
Narcís Calvet / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |