Multiple Pie Series - Titles for Each

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Kevin
Newbie
Newbie
Posts: 2
Joined: Mon Sep 13, 2004 4:00 am

Multiple Pie Series - Titles for Each

Post by Kevin » Wed Mar 15, 2006 3:11 am

I have multiple Pie Series and I would like to label each series from the legend so that users can see which series is which. Any way to do this?

Thanks,

Kevin

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Mar 15, 2006 9:52 am

Hi Kevin,

Yes, when setting the ChartRect for each pie you can custom write the title to TChart's canvas doing something like this:

Code: Select all

procedure TForm1.Series1BeforeDrawValues(Sender: TObject);
begin
  Chart1.ChartRect:=Rect(10,10,Chart1.Width div 2, Chart1.Height);
  WriteSeriesName((Sender as TChartSeries).Name);
end;

procedure TForm1.Series2BeforeDrawValues(Sender: TObject);
begin
  Chart1.ChartRect:=Rect(Chart1.Width div 2,10,Chart1.Width, Chart1.Height);
  WriteSeriesName((Sender as TChartSeries).Name);
end;

procedure TForm1.WriteSeriesName(Name: String);
var Width: Integer;
begin
  Width:=Chart1.ChartRect.Right-Chart1.ChartRect.Left;
  Chart1.Canvas.TextOut(Chart1.ChartRect.Left+(Width div 2),
                        Chart1.ChartRect.Top+50,Name);
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
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply