Breaking TLineSeries

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
FM
Newbie
Newbie
Posts: 7
Joined: Mon Apr 19, 2004 4:00 am

Breaking TLineSeries

Post by FM » Thu Sep 15, 2005 4:06 pm

I have to draw a TLineSeries breaking it in some points.
For example, points 1 to 10 must be connected, and also points 11 to 20, but point 10 and 11 must be not connected.
Is it possible?

Thanks

Best Regards

FM

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Fri Sep 16, 2005 7:48 am

Hi FM,

Yes, this is possible adding null values to the series:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Randomize;

  for i:=0 to 20 do
    if i=11 then Series1.AddNull('')
    else Series1.Add(random);
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

FM
Newbie
Newbie
Posts: 7
Joined: Mon Apr 19, 2004 4:00 am

Post by FM » Sun Sep 18, 2005 9:29 am

Hi Narcis,
if I use Series.AddNull for point 11, like in your example, I can't see this point on the graph.
Line breaks on point 10 and restarts on point 12; instead I need to see also point 11, and the line has to break on point 10 and to restart just on point 11.

Best regards

FM

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Sep 19, 2005 10:58 am

Hi FM,

To achieve what you request you have 2 options:

1) Using a TLineSeries and adding an additional null point between the two points where the gap has to be:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  Randomize;

  for i:=0 to 20 do
  begin
    if i=11 then Series1.AddNullXY(i-0.5,random);
    Series1.AddXY(i,random);
  end;
end;
2) Using a TPointSeries and TChart's OnAfterDraw event to custom draw a line between the points you want need and not drawing the line for the null point gap:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
begin
  Series1.FillSampleValues();
  Series1.Pointer.Visible:=false;
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
var
  Index: Integer;
begin
  With Chart1.Canvas, Series1 do
    for Index:=1 to Count-1 do
      if Index <> 11 then
      begin
        MoveTo(CalcXPos(Index-1),CalcYPos(Index-1));
        LineTo(CalcXPos(Index),CalcYPos(Index));
      end;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply