C
CHART * ChCreate( WORD ID, SHORT left, SHORT top, SHORT right, SHORT bottom, WORD state, DATASERIES * pData, CHARTPARAM * pParam, GOL_SCHEME * pScheme );
Overview
This function creates a CHART object with the parameters given. It automatically attaches the new object into a global linked list of objects and returns the address of the object.
Input Parameters
Input Parameters |
Description |
WORD ID |
Unique user defined ID for the object instance. |
SHORT left |
Left most position of the object. |
SHORT top |
Top most position of the object. |
SHORT right |
Right most position of the object. |
SHORT bottom |
Bottom most position of the object. |
WORD state |
Sets the initial state of the object. |
DATASERIES * pData |
Pointer to the data for the contents of the chart. NULL can be assigned initially when creating the object. |
CHARTPARAM * pParam |
Pointer to the chart parameters. NULL can be assigned initially when creating the object and the chart parameters can be populated using the API provided. |
GOL_SCHEME * pScheme |
Pointer to the style scheme used. When set to NULL, the default style scheme will be used. |
Returns
Returns the pointer to the object created.
Preconditions
none
Side Effects
none
Example
extern const FONT_FLASH GOLSmallFont; extern const FONT_FLASH GOLMediumFont; // Note that strings are declared as such to cover cases // where XCHAR type is declared as short (2 bytes). XCHAR ChTitle[] = {'E','x','a','m','p','l','e',0}; XCHAR SampleName[] = {'C','a','t','e','g','o','r','y',0}; XCHAR ValueName[] = {'#','H','i','t','s',0}; XCHAR SeriesName[2] = { {'V','1',0}, {'V','2',0}, }; V1Data[2] = { 50, 100}; V2Data[2] = { 5, 10}; GOL_SCHEME *pScheme; CHART *pChart; CHARTPARAM Contents; WORD state; pScheme = GOLCreateScheme(); state = CH_BAR|CH_DRAW|CH_BAR_HOR; // Bar Chart to be drawn with horizontal orientation pChart = ChCreate(0x01, // ID 0, 0, // dimensions GetMaxX(), GetMaxY(), state, // state of the chart NULL, // data not initialized yet NULL, // no parameters yet pScheme); // style scheme used if (pMyChart == NULL) // check if chart was allocated memory return 0; ChSetTitleFont(pChart, (void*)&GOLMediumFont); ChSetTitle(pChart, ChTitle); // set the title // set the grid labels and axis labels font ChSetGridLabelFont(pChart, (void*)&GOLSmallFont); ChSetAxisLabelFont(pChart, (void*)&GOLSmallFont); // set the labels for the X and Y axis ChSetSampleLabel(pChart, (XCHAR*)SampleName); ChSetValueLabel(pChart, (XCHAR*)ValueName); ChAddDataSeries(pChart, 2, V1Data, (XCHAR*)SeriesName[0]); ChAddDataSeries(pChart, 2, V2Data, (XCHAR*)SeriesName[1]); // set the range of the sample values ChSetValueRange(pChart, 0, 100); // show all two samples to be displayed (start = 1, end = 2) ChSetSampleRange(pChart, 1, 2); GOLDraw(); // draw the chart