CChartData::SetData


BOOL SetData( T *data, int nDims, int *dimArray );

Parameters

Returns

A boolean representing whether the data set was sucessfully created.

Description

This function sets the data. If data already exists, it is deleted before copying over the new data. This function uses double-precision floating point for internal storage. Since the data is copied to a new array, the data pointed to by data may be safely destroyed after calling SetData.

The format of a data set is row major. Thus, for an image of dimensions 512x512, the data should be stored as

Row0.Col0 Row0.Col1 ... Row0.Col511 Row1.Col0 Row1.Col1 ... Row511.Col511

For XY data, such as used with CXYChart, the data is also row major. Row 0 is the X data, and Row 1 is the Y data. So the X data should be stored in its entirety, followed by the Y data.
int		*data, i, dims[] = {2,25};
CChartData	dataSet;

// allocate data
data = malloc( 2 * 25 * sizeof( int ) );

// initialize data to some values
// We'll do y = 2 * x + 1
for( i = 0; i < 25; i++ )
{
   data[i] = i;   // X Values
   data[i+25] = 2 * i + 1;   // Y Values
}

dataSet.SetData( data, 2, dims );

free( data );


CChartData Reference | CPlot Reference