Table Of Contents

Graph IDEProgramming ► Scatter

The following is a complete script for programming a Scatter graphic. It computes a somewhat circular distribution of points and also assigns a bubble value. For this to work, the scatter graphic must have been made with a point tag marker.

/* Declarations */

double cos(double a);
double sin(double a);

@@class() Scatter:Object

@@method(public, class) (id)alloc;
@@method(public, instance) (id)init;
@@method(public, instance) (void)emptyData;
@@method(public, instance) (unsigned)animationCount;
@@method(public, instance) (void)appendXValue:(double)xValue yValue:(double)yValue;
@@method(public, instance) (void)setCurveRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)appendBubbleValue:(double)aValue;
@@method(public, instance) (void)appendMarkerRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha;
@@method(public, instance) (void)release;

@@end

/* Execution block */

{
id myScatter;
int ii;
double xValue, yValue;
unsigned animationCount;
double red, green;

myScatter = [[Scatter alloc] init];

animationCount = [myScatter animationCount];

printf("animationCount: %d\n", animationCount);

/*
Empty the data and then append new data.
*/

[myScatter emptyData];

for(ii = 0; ii < 20; ii++)
{
red = (animationCount % 10) / 10.0;
green = (animationCount % 30) / 30.0;
xValue = cos(ii * .02) + red * sin(ii * .01);
yValue = sin(ii * .02);

[myScatter appendXValue:xValue yValue:yValue];
[myScatter appendMarkerRed:red green:0.0 blue:1.0 alpha:1.0];
[myScatter appendBubbleValue:(ii * 1.0)];
}

[myScatter release];

}

The general API is define in the section Graphic. The following is API description specific to the Scatter graphic.

@@method(public, instance) (void)appendXValue:(double)xValue yValue:(double)yValue;
  Call like this:

[myScatter appendXValue:xValue yValue:yValue];

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:

[myScatter appendMarkerRed:0.5 green:0.4 blue:1.0 alpha:1.0];

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:

[myScatter appendSegmentRed:0.5 green:0.4 blue:1.0 alpha:1.0];

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:

[myScatter appendBubbleValue:aValue];

Appends aValue to the list of bubble values for the graphic. aValue must be of type double.

@@method(public, instance) (void)emptyData;
  Call like this:

[myScatter emptyData];

Removes (empties) all data from the graphic. Call this right before adding new data points.




© Copyright 1993-2022 by VVimaging, Inc. (VVI); All Rights Reserved. Please email support@vvi.com with any comments you have concerning this documentation. See Legal for trademark and legal information.