Page 1 of 1

Point3D with different color?

Posted: Sat May 31, 2008 11:12 am
by 9349911
Hi !

I have just started drawing GPS information to TChart. And it works very well (and easy) if I use TPoint3D.

But it would be great to have the lines between the 3D points in different colors. So it would be possible to view speed information within the GPS 3D data.
So it should look like this (the red / blue line):
Image

This example only uses two colors but I think you could imagine what I´m thinking about.

I tried something like this:

Code: Select all

  Series1.pen.color := RGB(255, 255, 0);
  Series1.AddXYZ(1, 2, 3);
  Series1.pen.color := RGB(255, 0, 0);
  Series1.AddXYZ(3, 20, 4);
  Series1.pen.color := RGB(0, 0, 255);
  Series1.AddXYZ(3, 20, 40);
But in this case only the last color is used by TChart - for the whole graph.

Is it generally possible to have different colors for the lines between the 3D points?

Posted: Mon Jun 02, 2008 1:45 pm
by narcis
Hi Dominik,

Yes, you can hide series' lines and customly draw your own as shown here:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  With Series1 do
  begin
    AddXYZ(random,random,random, '', clRed);
    AddXYZ(random,random,random, '', clBlue);
    AddXYZ(random,random,random, '', clGreen);
    AddXYZ(random,random,random, '', clYellow);
    AddXYZ(random,random,random, '', clWhite);
    LinePen.Visible:=false;
  end;
end;

procedure TForm1.Series1BeforeDrawValues(Sender: TObject);
var i: integer;
begin
  With Chart1.Canvas, Series1 do
  begin
    for i:=0 to Count-2 do
    begin
      Chart1.Canvas.Pen.Color:=ValueColor[i];
      MoveTo3D(CalcXPos(i),CalcYPos(i),CalcZPos(i));
      LineTo3D(CalcXPos(i+1),CalcYPos(i+1),CalcZPos(i+1));
    end;
  end;
end;

Posted: Mon Jun 02, 2008 1:47 pm
by 9349911
Hi Narcis,

oh that´s the trick :D

I will give it a try. Thx for the moment. 8)

Posted: Wed Jun 04, 2008 4:48 am
by 9349911
Works perfect Narcis.

Thx !