Downsampling without using an additional series.

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Freddy
Newbie
Newbie
Posts: 2
Joined: Mon Oct 31, 2016 12:00 am

Downsampling without using an additional series.

Post by Freddy » Tue Dec 20, 2016 1:38 pm

Hello,

I would like to use the downsampling function to significantly reduce the amount of datapoints to speed up my application. In the demo example for downsampling, series2 uses series 1 as a datasource. How can I downsample series 1 without needing another series?

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

Re: Downsampling without using an additional series.

Post by Yeray » Wed Dec 21, 2016 8:25 am

Hello,

All the functions in TeeChart need a series attached to draw the data calculated. You can use the same series you are using as DataSource, just note you'll be loosing the origin values doing it.
In the following example I'm using two charts. In the first chart I'm using a new TLineSeries to draw the output of the function and I'm hiding the source series. In the second chart I'm using the same origin series as output for the function.
The result is the same in both charts:

Code: Select all

uses TeeDownSampling;

var lineSeries1, lineSeries2: TLineSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=False;
  Chart2.View3D:=False;
  Chart1.Legend.Visible:=False;
  Chart2.Legend.Visible:=False;

  lineSeries1:=Chart1.AddSeries(TLineSeries) as TLineSeries;
  lineSeries2:=Chart2.AddSeries(TLineSeries) as TLineSeries;

  lineSeries1.FillSampleValues(2000);
  lineSeries2.DataSource:=lineSeries1;
end;

procedure TForm1.Button1Click(Sender: TObject);
var downSamplingFunction1, downSamplingFunction2: TDownSamplingFunction;
    downSamplingSeries: TLineSeries;
begin
  downSamplingSeries:=Chart1.AddSeries(TLineSeries) as TLineSeries;
  downSamplingSeries.DataSource:=lineSeries1;
  downSamplingSeries.Color:=lineSeries1.Color;

  downSamplingFunction1:=TDownSamplingFunction.Create(Self);
  downSamplingSeries.SetFunction(downSamplingFunction1);
  downSamplingFunction1.Tolerance:=10;
  lineSeries1.Visible:=False;

  downSamplingFunction2:=TDownSamplingFunction.Create(Self);
  lineSeries2.SetFunction(downSamplingFunction2);
  downSamplingFunction2.Tolerance:=10;
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