Page 1 of 1

Line series - line colors

Posted: Tue Apr 30, 2013 4:49 pm
by 9347097
I have a LS where the points are different colors. The line between two points is currently the color of the point to the right. Is there a way to make the line color to be the color of the *left* point?

(Why: the point colors represent a financial state at the beginning of a year and that state continues until the next year. So using the state color of the next year (the right point) makes no sense.)

Thanks.

Re: Line series - line colors

Posted: Fri May 03, 2013 11:22 am
by yeray
Hi Jim,

I'm afraid the only way I can think on is to change how you are adding the points, moving the colors a position to the right. Ie, instead of this:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  with Chart1.AddSeries(TLineSeries) as TLineSeries do
  begin
    Pen.Width:=2;

    Add(random*100, 'yellow', clYellow);
    Add(random*100, 'red', clRed);
    Add(random*100, 'green', clGreen);
    Add(random*100, 'blue', clBlue);
    Add(random*100, 'gray', clGray);
    Add(random*100, 'maroon', clMaroon);
  end;
end;
You could do this:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  with Chart1.AddSeries(TLineSeries) as TLineSeries do
  begin
    Pen.Width:=2;

    Add(random*100, 'yellow', clTeeColor);
    Add(random*100, 'red', clYellow);
    Add(random*100, 'green', clRed);
    Add(random*100, 'blue', clGreen);
    Add(random*100, 'gray', clBlue);
    Add(random*100, 'maroon', clGray);
  end;
end;
Alternatively, if you can't change the way you add the point colors, you could loop the array of colors to move them. Ie:

Code: Select all

uses Series;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  with Chart1.AddSeries(TLineSeries) as TLineSeries do
  begin
    Pen.Width:=2;

    Add(random*100, 'yellow', clYellow);
    Add(random*100, 'red', clRed);
    Add(random*100, 'green', clGreen);
    Add(random*100, 'blue', clBlue);
    Add(random*100, 'gray', clGray);
    Add(random*100, 'maroon', clMaroon);
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
var i: Integer;
begin
  with Chart1[0] do
  begin
    for i:=Count-1 downto 1 do
      ValueColor[i]:=ValueColor[i-1];

    //ValueColor[0]:=clTeeColor;
  end;
end;