Graph IDE ► Programming ► Function
The following is a complete script for programming a Function. It computes a cosine curve and then duplicates that curve five times using the recur method. The cosine is shifted up upon each recursion to demonstrate how to alter the data based upon recursion. Since it is often the case that a graph has multiple curves that are computed based upon data, the recur method is very important to the function graphic.
|
The general API is define in the section Graphic. The following is API description specific to the Function graphic.
@@method(public, instance) (void)appendXValue:(double)xValue yValue:(double)yValue;
| |
Call like this:
Appends the x and y values to the list of data points for the graphic. The x and y values forms a 2D point. Each value must be of type double. | |
@@method(public, instance) (void)appendMarkerRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
| |
Call like this:
That appends the marker color to the red, green, blue and alpha values of 0.5, 0.4, 1.0 and 1.0 respectively. Those values must be between 0.0 and 1.0. An alpha of 0.0 is transparent while 1.0 is completely opaque. Each argument must be a number literal or a variable (or expression) of type double. Note that this call must accompany a appendXValue:xValue yValue: call in order to synchronize the parameters that depend upon sequence index. | |
@@method(public, instance) (void)appendSegmentRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
| |
Call like this:
That appends the segment color to the red, green, blue and alpha values of 0.5, 0.4, 1.0 and 1.0 respectively. Those values must be between 0.0 and 1.0. An alpha of 0.0 is transparent while 1.0 is completely opaque. Each argument must be a number literal or a variable (or expression) of type double. Note that this call must accompany a appendXValue:xValue yValue: call in order to synchronize the parameters that depend upon sequence index. | |
@@method(public, instance) (void)appendBubbleValue:(double)aValue;
| |
Call like this:
Appends aValue to the list of bubble values for the graphic. aValue must be of type double. | |
@@method(public, instance) (void)sort;
| |
Call like this:
Sorts the data points in x-order. You should attempt to append the data points in x-ascending order but if that is not possible then call this sort method after appending all data points. The points must be x-ascending. | |
@@method(public, instance) (void)emptyData;
| |
Call like this:
Removes (empties) all data from the graphic. Call this right before adding new data points. |