Page 1 of 1

Drawing the n latest TPoint3DSeries points

Posted: Mon Mar 13, 2017 4:33 pm
by 16580178
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?

Re: Drawing the n latest TPoint3DSeries points

Posted: Tue Mar 14, 2017 10:51 am
by yeray
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.

Re: Drawing the n latest TPoint3DSeries points

Posted: Tue Mar 14, 2017 10:58 am
by 16580178
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?

Re: Drawing the n latest TPoint3DSeries points

Posted: Tue Mar 14, 2017 11:39 am
by yeray
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);

Re: Drawing the n latest TPoint3DSeries points

Posted: Tue Mar 14, 2017 1:22 pm
by 16580178
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?

Re: Drawing the n latest TPoint3DSeries points

Posted: Wed Mar 15, 2017 7:52 am
by yeray
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.

Re: Drawing the n latest TPoint3DSeries points

Posted: Wed Mar 15, 2017 8:08 am
by yeray
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;