Drawing the n latest TPoint3DSeries points

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
MatsOle
Newbie
Newbie
Posts: 5
Joined: Tue Feb 28, 2017 12:00 am

Drawing the n latest TPoint3DSeries points

Post by MatsOle » Mon Mar 13, 2017 4:33 pm

I want to set parameters to a TPoint3DSeries so that only the n latest points in the series are drawn.

I have tried to use the following code in the procedure Chart1BeforeDrawSeries(Sender: TObject);

Code: Select all

 if Form1.Series6.LastValueIndex > PointsToDraw
 then StartIndex:=Form1.Series6.LastValueIndex - PointsToDraw
 else StartIndex:=0;
 Form1.Series6.DrawSeriesForward(StartIndex);
This is not working.

How is it done?

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

Re: Drawing the n latest TPoint3DSeries points

Post by Yeray » Tue Mar 14, 2017 10:51 am

Hello,

I see three alternatives depending on your setup:
- If the points are x-ordered you can just set the bottom axis with SetMinMax.
- If you aren't going to show the first points later, you can just remove the unwanted points.
- You could set as nulls the point that you don't want to be shown.
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

MatsOle
Newbie
Newbie
Posts: 5
Joined: Tue Feb 28, 2017 12:00 am

Re: Drawing the n latest TPoint3DSeries points

Post by MatsOle » Tue Mar 14, 2017 10:58 am

My points are time-ordered, ie I want to draw them in the order they arrive.

I want to show the first points later.

How do I set a point to null?

Is it possible to reset a point to its original value after it has been set to null?

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

Re: Drawing the n latest TPoint3DSeries points

Post by Yeray » Tue Mar 14, 2017 11:39 am

Hello,

You can set a null point as follows:

Code: Select all

Series1.SetNull(ValueIndex);
This action sets its color to transparent so it won't be drawn. Later, you can set it visible again and the value is preserved:

Code: Select all

Series1.SetNull(ValueIndex, False);
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

MatsOle
Newbie
Newbie
Posts: 5
Joined: Tue Feb 28, 2017 12:00 am

Re: Drawing the n latest TPoint3DSeries points

Post by MatsOle » Tue Mar 14, 2017 1:22 pm

Thanks,

This works but have a drawback in that when you try to zoom in with a zoom rectangle
and hit a point that is invisible the zoom rectangle is not shown.

When setting Series6.Visible:=false, which hides the complete series, the zooming works fine.

Is it possible to set Visible:=false on individual points to avoid the zoom problem?

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

Re: Drawing the n latest TPoint3DSeries points

Post by Yeray » Wed Mar 15, 2017 7:52 am

Hello,

Another alternative would be to inherit TPoint3DSeries to add an array of booleans (ie VisiblePointer) to control the visibility of the individual points using OnGetPointerStyle event or overriding DrawPointer.
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

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

Re: Drawing the n latest TPoint3DSeries points

Post by Yeray » Wed Mar 15, 2017 8:08 am

Yeray wrote:Hello,

Another alternative would be to inherit TPoint3DSeries to add an array of booleans (ie VisiblePointer) to control the visibility of the individual points using OnGetPointerStyle event or overriding DrawPointer.
For TPoint3DSeries the second technique should be a bit different. Here an example:

Code: Select all

uses Series, TeePoin3;

type
  TMyPoint3DSeries = class(TPoint3DSeries)
    protected
      Procedure DrawValue(ValueIndex:Integer); override;
    public
      VisiblePointer: array of Boolean;
  end;

Procedure TMyPoint3DSeries.DrawValue(ValueIndex:Integer);
begin
  Pointer.Visible:=VisiblePointer[ValueIndex];
  inherited;
end;

procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
begin
  Chart1.Legend.Alignment:=laBottom;

  for i := 0 to 2 do
    with Chart1.AddSeries(TMyPoint3DSeries) as TMyPoint3DSeries do
    begin
      FillSampleValues(1000);
      LinePen.Visible:=False;
      UseColorRange:=False;

      SetLength(VisiblePointer,Count);
      for j:=0 to Count-1 do
        VisiblePointer[j]:=j mod 200=0;
    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