Page 1 of 1

Different gradient colors for different slices

Posted: Mon Apr 06, 2009 10:31 am
by 10552762
Hi,

Is it possible to have a different gradient color for different slices?
For example: a pie chart with 3 slices:
slice 1: 30% red gradient,
slice 2: 50% green gradient,
slice 3: 20% orange gradient

also, is this possible with donuts?

another solution might be to have a third dimension for each slice.

Posted: Mon Apr 06, 2009 2:02 pm
by yeray
Hi Tom,

I'm afraid that it wouldn't be easy to define custom gradients for each slice. But it would be easy if you could start with a shared color, white for example:

Code: Select all

uses Series, TeCanvas;

var pie1: TPieSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  pie1 := TPieSeries.Create(nil);
  Chart1.AddSeries(pie1);

  pie1.Add(30,'',clRed);
  pie1.Add(50,'',clGreen);
  pie1.Add(20,'',RGB(255,128,64));

  pie1.Gradient.Visible := true;
  pie1.Gradient.StartColor := clWhite;
  pie1.Gradient.Balance := 100;
  pie1.Gradient.Direction := gdFromBottomLeft;
end;