Additional series for SGraph.

For my own use I wrote series which get data from external data storage and draw it. I was going to develop this series, unfortunately I still have not time and it works. Because of I received request for series like this I decide to publish current version. There are 2 class: 
Tsp_DrawPoints=class(Tsp_DataSeries) and
Tsp_ndsXYLine=class(Tsp_DrawPoints).
Tsp_DrawPoints can be used to derive new series, it contains all draw primitives and main functionality, from this one you can derive new series with arbitrary data storage engine. Tsp_ndsXYLine source is example how to do this. Tsp_ndsXYLine itself permits you keep data separately from series in your own variables (or may be files) and draw it through callback functions (events) interface.

How it works?

Tsp_ndsXYLine in sense of drawing is same to Tsp_XYLine   (see sgr_def.hlp for draw properties of Tsp_XYLine). But Tsp_ndsXYLine has not internal data storage, it uses callback functions (events) to receive date for drawing. There are several events

TspGetXYCountEvent=procedure(DS:Tsp_ndsXYLine) of object;
TspGetXYEvent=procedure(DS:Tsp_ndsXYLine; idx:integer) of object;
TspGetMinMaxEvent=function(DS:Tsp_ndsXYLine; var V:double):boolean of object;

and they published in Tsp_ndsXYLine as next properties

published
property OnGetXYCount: TspGetXYCountEvent read FOnGetXYCount write FOnGetXYCount;
property OnGetXY: TspGetXYEvent read fOnGetXY write fOnGetXY;
property OnGetXMin: TspGetMinMaxEvent read fOnGetXMin write fOnGetXMin;
property OnGetXMax: TspGetMinMaxEvent read fOnGetXMax write fOnGetXMax;
property OnGetYMin: TspGetMinMaxEvent read fOnGetYMin write fOnGetYMin;
property OnGetYMax: TspGetMinMaxEvent read fOnGetYMax write fOnGetYMax;
end;
You write handlers for this events where inform series about data. Number of points and current point value are set in handlers as values for public series fields Count and XV,YV.

Here simple demo program eds_demo is included. In this program we place data in array Data[0..maxi-1,xi..yi] and write handlers which connect series with this data storage. When series begin to draw data it call OnGetXYCount where we define how many times it will call for the data points

procedure TForm1.sp_ndsXYLine1GetXYCount(DS: Tsp_ndsXYLine);
begin
 DS.Count:=maxi;
end;

Then series call Count times this handler

procedure TForm1.sp_ndsXYLine1GetXY(DS: Tsp_ndsXYLine; idx: Integer);
begin
DS.XV:=Data[idx,xi];
DS.YV:=Data[idx,yi];
end;

to receive data. If series has marker and lines it call this twice for every points. idx are changed from 0 to Count-1 and indicate current point number.

When series begin to draw or when plot is making autoscaling and ask series for limits, series need information about max and min of data values. For that it calls handlers like this one (see more in help file for the function GetXMax)

function TForm1.sp_ndsXYLine1GetXMax(DS: Tsp_ndsXYLine;
var V: Double): Boolean;
begin
Result:=True; //True because we have info about Max of X data
V:=MaxX;
end;

For information about series and plot see sgr_def.hlp file.

Sergei P. Pod'yachev. Novosibirsk, Russia.
WWW:   pod0.chat.ru
www.iae.nsk.su/~lab12/pod

List100