Roadmap Tutorial API's: XYGraph Axes etc Series Stats
TxyGraph Series 
The TSeries object encapsulates data and appearance settings
for each series of the graph. Series are created on the fly as
required. TSeries is a descendant of TDataSeries, from which it
inherits many properties and methods.
Data is maintained internally in a linked list of points,
sorted by x value. Each point has an associated index which does
not change for the lifetime of the point, and x,y value, and an r
value (see statistics below).
There are several properties for accessing the data: ValueAt,
AllPoints, PointCount, which are all x value based, and
PointbyIndex which is based on the index
These properties generally use the following methods, which
are also available: Add, AddPointSeries, AddPoints, GetValue,
GetPoint, DeleteValue, DeletePoint. In addition, sequential
access to the list is available using the following routines:
GetFirstPoint, GetNextPoint, UpdateCurrentPoint,
DeleteCurrentPoint
Statistical analyses and regression are only available if the
conditional define STATISTICS is turned on in the code. This
conditional define does not affect published properties. The
conditional define is present to remove the stats routines from
the compiled code.
There is a theoretical limit on the number of points in a
series of 2,147,483,647 points, but since this is >40,000 Mb
of data, it's probably not a problem. Effectively then, the only
limit on the amount of data is available memory. Each point takes
22 bytes of memory. Spline and DWLS regression require additional
memory, 22 x RegControl2 bytes. Passing/Bablok regression can
require exorbitant amounts of memory 8 x (number of points)^2 +
more.
Internal maintenance
- property SeriesIndex: Longint
- property NextSeries: TSeries
used by TxyGraph. You can use next series to move through
the list of defined series if you wish
Drawing
- procedure Draw
Do a redraw. You should never need to use this
- property graph: TXyGraph
Handle to graph that owns this series. You shouldn't need
to use this
- property HoldUpdates: Boolean
- property Active: Boolean
- property DrawLine: Boolean
- property DrawPoints: Boolean
- property FillPoints: Boolean
- property LineColor: TColor
- property PointColor: TColor
- property ZoundsColor: TColor
- property PointShape: et_PointShape
valid options for PointShape are: ps_square, ps_circle,
ps_diamond, ps_cross, ps_wide
- property LineStyle: TPenStyle
- property PointSize: Word
Point size is internally constrained to even values.
- property WhichYAxis: TAxis
- property UpperBound:double
- property LowerBound:double
- property BoundsType: et_BoundType
bt_None, bt_AsSet, bt_1SD, bt_2SD, bt_3SD, bt_allSD lines
will be drawn at 1,2,3 SD on the Y axis using the
calculated SD
- property BoundsLineStyle: TPenStyle
- property RegressionLineColor: TColor
- property RegressionLineStyle: TPenStyle
- property LegendStatus:TLegendStatus
lsNone - not included in legend
lsNameOnly - only name is shown
lsPoints - show name and points
lsLines - show name and line style
lsAll - show name, points and lines
All the properties from here on are shared with
TDataSeries
To use TDataSeries, add xydata to the programs uses clause,
and create it like so:
dataseries1 := TDataSeries.create(nil);
use it as you would use a series in a TxyGraph. When you have
finished with it, call dataseries1.free;
General Admin
- SeriesName:string
- AutoZero: Boolean
Setting Autozero will cause the zerovalue to be ignored
and the internal offset will be set at the lowest value
in the series
- InternalZero: Double
InternalZero is subtracted from the Y value before
anything else is done
Data Manipulation
pgPoint = ^tgPoint;
tgPoint = record
i: longint;
xv, yv, rv: Double;
next: pgPoint;
end;
- Data:pgpoint
- read only handle to the series data.
- Tolerance: Double
Tolerance is the amount of variance allowed between 2
different floating point numbers before they are
considered to be different when inserting or looking up
data. Tolerance defaults to 0.
- ValueAt[x: Double]: Double
Gets or sets the point at value x. ValueAt is the default
array for the TSeries Object. While this is a very
convenient interface, allowing assignment to a point by
xyGraph1[i][1.3] := 4.5, for instance, there is no error
protection, and it is not really appropriate when
AllowDuplicates = true.
- AllPoints[x: Double]: pGPoint
returns a pgpoint pointer to a list containing all the
points with the same value as x. Read only.
- PointByIndex[i: longint]: Double
gets or sets the y value of the point with an index i.
- PointCount[x:Double]:Word
gets the number of points with a x value of x.
- AllowDuplicates: Boolean
- function Add(x, y: Double): longint;
Adds a point (x,y). If Allowduplicates is false it will
replace any point with x value same as x, otherwise it
will add a new point
- procedure AddPointSeries(x:Double;
y:array of Double);
Adds a series of points at the same x
- procedure AddPoints(p:array of
TDoublepoint);
Adds a series of points.
TDoublePoint = record x,y:double; end;
- function GetValue(curr: longint; var
index: longint;var x, y, r: Double): Boolean;
returns the value of the most recently added point at x.
Because multiple points may exist with the same x value,
the getvalue function allows for enumeration through them
all.
To look up the first point with x value = x, call
getvalue with curr = 0. This will return the index of the
point, and it's x,y and regression values. To get the
next point, call the routine again, passing the index of
the last point as curr. When the function returns an
index of 0, or false, there is no more points left.
- function GetPoint(var index: longint;var
x, y, r: Double): Boolean;
function getpoint returns the point with an index
corresponding to index. It returns the x,y values for the
point and also the regression value (see Statistics for an explanation)
- function DeleteValue(x: Double):
Boolean;
deletes all points found in the series with an x value of
x. returns true if any points are deleted.
- function DeletePoint(index: longint):
Boolean;
Deletepoint deletes the point with an index equal to
index. returns true if any points are deleted.
- function EliminateDuplicates: Boolean;
Eliminates any duplicate x values in a series.
Automatically called when AllowDuplicates is set to
false.
- function GetFirstPoint(var x, y, r:
Double; var index: longint): Boolean;
- function GetNextPoint(var x, y, r:
Double; var index: longint): Boolean;
steps through the data sequentially returns false when
having read past the end of the data)
- procedure UpdateCurrentPoint(y: Double);
- function DeleteCurrentPoint(var x, y, r:
Double; var index: longint): Boolean;
which deletes the just-read point, and performs a
GetNextPoint (so returning the data of the point
following the deleted one).
- procedure Clear;
delete all the data
Filing Procedures
- procedure ReadFromStream(r:TxyReader);
virtual;
- procedure SaveToStream(w:TxyWriter;
savedata:boolean); virtual;
- procedure SaveToFile(fname:string);
- procedure readFromFile(fname:string);
Stats
- XMinVal:double
- XMaxVal:double
- YMinVal:double
- YMaxVal:double
The following properties are only available if STATISTICS is
defined
- procedure DoRegression;
- internal use
- procedure getintercepts(y: double; var
result: et_interceptResult;var count: word; var
intercepts: PsPoint);
- get the intercepts of the regression line for a y
value. (multiple results may be returned).
- procedure disposeintercepts(var
intercepts:psPoint);
- RegType: et_regressions - see table
below
- RegControl1: LongInt
the number of points used in Spline and DWLS regression.
The more points used, the smoother the line will be, and
the slower it will be to calculate
- RegControl2: Double
The meaning RegControl2 depends on the type of
regression.
Running Average: for the average: avg = (1-RegControl2) *
xi + RegControl2 * xi-1
Spline: initial gradient
DWLS: tension of fitting. Best around 0.0005
- XStats: TDataStats
- YStats: TDataStats
- CompStats: TCompStats
- RegressionData: pgPoint
read only pgpoint handle to the regression data generated
by Spline and DWLS regression.
See Statistics for further information
Memory protection
- OnTooManyPoints: TNotifyEvent
this event is overriden in TSeries to call
TxyGraph.OnTooManyPoints
- PointWarningLimit: longint
- PointNumber:longint
Hooks
- Hooks [o:tobject] :TDataChangeEvent
see Hooking for further info
Data Acquisition
(see tutorial 2 for further info)
- DataSrc:TDataSrc
ds_Manual - data is added manually
ds_TextFile - data is taken from a text file
"SrcInfo"
ds_DataSet - data is taken from the datasource named
"SrcInfo"
ds_BDETable - data is taken from the table identified
using SrcInfo = "alias:tablename"
ds_BDEQuery - data is taken from a datasource using a BDE
query "alias:SQL"
ds_xyHolder - data is taken from a datasource with ID =
srcinfo
ds_ODBC - data taken from the ODBC DSN
"SrcInfo" - requires ODBCExpress
- SrcInfo:string
- TextFileByWidth:boolean
- HeaderCount:word
number of rows to skip at start
- TextSeparators:string
- TextMarkers:string
- XDataCol:String
use "(Col X)" for columns by number
- YDataCol:String
- RowHitFreq:word
- ColWidth:word
- RowChoice:TRowChoice
see Tutorial 2
- RowStart:double
- RowFinish:Double
- XFormat:TTxtFieldtype
ft_Number, ft_DateTime number or time when reading Text
Sources
- YFormat:TTxtFieldtype
- procedure refreshdata;
Actually load data - must be called to load data, not
called automatically