What is it. How it works. How to install.
I would like to derive new series with different method of data storage for my
component SGraph. For my own use I wrote series which
get data from external data storage and draw it. It works, but I hoped to improve it
and made some more. But unfortunately I still have not time for that. 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.
Tsp_ndsXYLine in sense of drawing is same to (see sgr_def.hlp for draw properties of Tsp_XYLine). But Tsp_ndsXYLine has not internal data storage, it asks for them when it need to draw them. 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.
Unzip files into directory where SGraph files are placed. Start Delphi and select Install Component menu item, on page Into existed packet enter sgr_eds.pas as unit file and sgraph packet as packet. You can edit Register procedure in sgr_eds.pas if you want place component on tab differ then Samples. Then recompile packet and new series is ready to use.
Sergei. P. Pod'yachev. Novosibirsk, Russia.
WWW : www.iae.nsk.su/~lab12/pod