Page 1 of 1

Is it possible for TAreaSeries to display in three color ?

Posted: Fri Feb 22, 2008 5:41 am
by 9243843
Hi,

I am try to use TAreaSeries in three different colour, the X axis is based on date & time, then there are three different time frames, in each time frame, I need TAreaSeries in different colors. Is it possible ? thanks.

Daniel

Posted: Fri Feb 22, 2008 9:12 am
by yeray
Hi Daniel,

You could set series' property "ColorEachPoint" to true and then assign the desired color to each point. Here is an example:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i, FirstRange, SecondRange: Integer;
begin
  Series1.ColorEachPoint := true;

  Series1.FillSampleValues(30);
  Series1.XValues.DateTime := true;
  Chart1.Draw;

  FirstRange := 10;
  SecondRange := 20;

  for i:=0 to FirstRange-1 do
  begin
    Series1.ValueColor[i]:= RGB(176,0,0);
  end;

  for i:=FirstRange to SecondRange-1 do
  begin
    Series1.ValueColor[i]:= clRed;
  end;

  for i:=SecondRange to Series1.Count-1 do
  begin
    Series1.ValueColor[i]:= rgb(255,100,100);
  end;
end;