Roadmap Tutorial API's: XYGraph Axes etc Series Stats
TxyGraph 3.0 Property and Method Reference 
If a property or method does not appear here I haven't
documented it because it does the standard VCL things
Other subclasses
Graph Status
- OnRescale: TNotifyEvent
- OnPaintEnd: TPaintEvent
Allows you to draw whatever you wish on the canvas
TPaintEvent = procedure (sender:TObject;
Canvas:TCanvas) of object;
- OnWantDesigner:TNotifyEvent
- Plotting:boolean
- turn this off if a series of updates are to be made -
save redrawing the screen continuously
Error Checking
- checkScales:boolean
The graph may not be able to draw either or both axes.
(eg, .Max < Min, or Min = 0 and LogScale). This
procedure returns true if the axes are able to be drawn
with the current values, false if not.
Each Axis also has a Checkscale function
The event OnScaleError will be called if these conditions
fail at run time
- OnScaleError: TNotifyEvent
- OnLogError: TSeriesEvent
called when a series with negative or zero values is
meant to be plotted on a logged axis
TSeriesEvent = procedure
(sender:TObject; index:integer) of object;
- OnTooManyPoints: TSeriesEvent
Notification that the number of points in a series has
exceeded the limit set (see TSeries). Points will
continue to be added, but the event will be called for
each point. This event is provided to help prevent nasty
memory hogging behaviour.
Data Routines
- Series[i:integer]: TSeries
Access to the series objects of TxyGraph. Each series is
a TSeries object that encapsulates data and drawing
settings. Series is the default property of TxyGraph, so
that xyGraph[1] is the same as xyGraph.series[1] (pascal
only). Although you can use a series[0] if you wish, the
0 generally has special meaning, and it's better not to
use it.Series are created on the fly as required. Each
time a series is created the event OnNewSeries is called,
to aid in debugging.
- OnNewSeries: TSeriesEvent
- Serieshandle:TSeries
- provided to iterate through existing series
- LastSeriesIndex:integer -
- function FindSeries(i:integer): Boolean
checks whether a series exists without creating it
- procedure ClearAll;
delete all series
- OnDeleteSeries: TSeriesEvent
Hooking other graph series
- procedure Hookseries(Source:TSeries;
Ahooktype:THooktype; Dest:Integer; WantPersist:boolean);
- procedure unhookseries(source:TSeries;
WantPersist:boolean);
- procedure HookedSeriesEvent(Sender:TObject;
TheMessage:TDSChangeType);
(see hooking series for help)
Marks
- procedure ClearMarks;
- procedure Addmark(id: Integer; x1,y1,
x2,y2: Double; c: Tcolor; name: string;
marktype:et_marktype; status:boolean);
Add an annotation to the graph. id is the index of the
mark. If no mark with an index of id is found, a new mark
will be created, otherwise the old will be written over.
mtXMark draws a mark on the x axis at point x1 across the
entire plot area.
mtYMark draws a mark on the y axis at point y1 across the
entire plot area
mtPoint draws a square around the point (x1,y1) with
width x2
mtLine draws a line from (x1,y1) to (x2,y2)
status: whether the mark is drawn under (before) or on
top of (after) the data. Constants drawBefore and
drawAfter are defined for use here
- function DeleteMark(id: Integer):
Boolean;
- see also appearance.showmarks
Mouse Things
- property HasDragged: boolean read
FHasDragged write SetHasDragged;
- whether the user has shift-dragged the graph to scale
it
- property DragAllowed: Boolean
whether the user can move the graph by shift-dragging (To
drag, left-click in the upper left hand margin. To
resize, right-click in the lower right hand margin.)
- function GetMouseX(x: Integer): Double;
- function GetMouseY(y: Integer): Double;
- these 2 functions return the values on the axes at the
current point of the graph
- function GetMouseY2(y: Integer): Double;
- function GetMouseVals(sN, x: Integer;
var index: Integer; var xNearest, yNearest: Double):
Boolean;
- returns the nearest point on the x axis for a
particuler series
- function findNearestPoint(var series,
x,y:integer):pgPoint;
- returns the nearest point to the given x,y or nil if no
data is present
- function GetMouseXY(sN, x, y: Integer;
var index: Integer; var xScaled, yScaled, xNearest,
yNearest: Double): Boolean;
- a wrapper for GetmouseX,Y and GetMouseVals
Printing
- procedure PrintOnPage;
- procedure Print;
PrintOnPage allows more than one gaph to be printed on a
page; calls to it must be preceded by BeginDoc amd followed by
EndDoc. Print prints only the current graph on its own sheet. The
graph is printed without change in aspect ratio. The size of the
printed graph is controlled by PrintScalePct, which makes the
dimension of the printed graph a percentage of the page dimension
(on the axis with the larger Screen/Page ratio) The location of
the upper left corner of the graph is controlled by
PrintX(Y)OffsetPct, which locate the corner as percentages of the
page height and width
Other Output forms
- procedure FillMetafile(wmf:TMetafile);
- procedure savetoWMF(const fname:string);
- procedure FillBitmap(bmp:TBitmap);
- procedure SaveToBitmap(const
fname:string);
Saving to Files etc
- procedure savetofile(fname:string;
savedata:boolean);
- procedure savetostream(f:TStream;
savedata:boolean);
- procedure readfromfile(fname:string);
- procedure readfromStream(f:TStream);
- procedure Assign(source:TPersistent);
override;
- procedure CopyToClipboard;
- procedure PasteFromClipboard;
see saving to files for more info
Function
- procedure DrawFunction(F: PlotFunction;
var parms; x1, x2: Double; color: TColor; style:
TPenStyle; steps: Word);
function f(x:Double; params):double;
See plotting functions for an
example