Page 1 of 1

Multiple Pie Series - Titles for Each

Posted: Wed Mar 15, 2006 3:11 am
by 9234136
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

Posted: Wed Mar 15, 2006 9:52 am
by narcis
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;