Line series - line colors

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Jim Green
Newbie
Newbie
Posts: 43
Joined: Thu Aug 03, 2006 12:00 am

Line series - line colors

Post by Jim Green » Tue Apr 30, 2013 4:49 pm

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.

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Line series - line colors

Post by Yeray » Fri May 03, 2013 11:22 am

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;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply