Roadmap Tutorial API's: XYGraph Axes etc Series Stats
All TxyGraph data is held in series.
TxyGraph has a property Series which you can use to access the data, so series are accessed like this:
xygraph1.series[1] (c++ xyGraph1->Series[1])
However since Series is declared as the default property of TxyGraph, a series can also be accessed in this fashion:
xygraph1[1] (pascal only)
and this is the method I use in my code and this help file.
Series are created on the fly as you use them. Simply refer to the new series when you want it, and it will suddenly exist. (note: TxyGraph declares an event OnNewSeries you can use to be informed of this. You might want to do this during development - it's too easy to accidentally refer to the wrong series).
You can destroy series by calling their free method:
xygraph1[1].free
Any series that you don't destroy will be cleaned up when the xyGraph is destroyed.
Data is stored internally as a linked list and each data point has an x value, a y value, and an associated index value. Primarily the data is accessed in terms of the x value, and this is at present t he only way to add new data points. Once the data exists, it can be accessed by either x value, or sequentially in the linked list. There's many more ways of accessing the data, but only the simplest is presented here (see TSeries reference for others).
The following discussion is only applicable when duplicate x values are not allowed (see below).
The statement
xygraph1[1][3.4] := 5.1 (c++ xygraph1->series[1]->ValueAt[3.4] = 5.1)
adds the point (3.4,5.1) to the data series with index 1. If a value already existed for x = 3.4, it will be replaced with 5.1.
The statement
y := xygraph[1][3.4]
will place the value for x = 3.4 in y. However, if there is no datapoint associated with x = 3.4, it will return 0, and there is no way to tell the difference between a 0 due to error and a valid 0. For this reason, I recommend using getvalue or prefacing the shortcut above with a call to xygraph1[1].pointcount[3.4] to find out whether a point exists at 3.4.
Delete points with the deletevalue routine:
xygraph1[1].deletevalue(3.4)
Tolerance is the difference between 2 numbers before they are considered to be different. The need for this arises because floating point computation is imprecise. Tolerance def aults to 0, but you might need to change it to allow for the imprecision.
If you need to have more than one y value for a given x value, you will have to set AllowDuplicates to true. This complicates the data handling, so you should only do this if you need to. AllowDuplicates defaults to false.
Preventing Screen redraws when adding a lot of data - use the property HoldUpdates to prevent continual redrawing or analysis of an active series while you're adding a lot of data.