Chapter 1:
Overview


 

PGSDK uses attributes to control the appearance of objects in a chart. An attribute can define the location, size, color, etc. of objects in the graph. An attribute can also enable or disable the drawing of an object. For all chart objects, attributes are retrieved and set using the Get/Set Attribute functions described in the PGSDK API Guide:

 

Get/SetGraphAttr: Get/Set the attribute for a specific object

 

Get/SetGraphAttrSI: Get/Set attribute for an item in a selection list

 

Get/SetGraphAttrSL: Get/Set attribute for the first item in a selection list

 

Some attributes can define the appearance of multiple objects or multiple instances of the same object. When this is the case, multiple definitions of the attribute can be specified and attached to specific objects. SetGraphAttr() lets you specify a particular object for which an attribute definition should be used. The following attribute settings define different colors for series one (Series_1) and two (Series_2) risers:

 

// Set the color of series 1
SetGraphAttr
(graphPtr,GRAPH_LAYER,O2D_RISER,Series_1,
     NULL_GROUPID, A_AREACOLOR_RGB,&myRGBstruct[1]);

 

// Set the color of series 2
SetGraphAttr(graphPtr,GRAPH_LAYER,O2D_RISER, Series_2,
     NULL_GROUPID, A_AREACOLOR_RGB,&myRGBstruct[2]);

 

SetGraphAttrSI() lets you modify an attribute for one item/object in a selection list. The following example sets the orientation of the text object identified by gpSelItem:

 

Orient = FONTORIENT_NORMAL;
SetGraphAttrSI(gpGraph,gpSelItem,A_FONTORIENT,&Orient);

 

SetGraphAttrSL() lets you direct the attribute definition to all items/objects in a selection list. The following example will change the color of all area objects in the selection list at gpList:

 

SetGraphAttrSL(gpGraph, gpList,A_AREACOLOR_RGB,&aRGB[i]);

 

This function will only choose objects in the selection list that are appropriate to the attribute being used. For example, A_AREACOLOR_RGB can only be applied to area objects. If there are no area objects in the selection list, SetGraphAttrSL() is ignored and a return code will indicate that no matching items were found.

 

In most cases, you do not need to specify an object or a particular instance (series and/or group ID) of an object in order to set or get an attribute. In many cases, the attribute is object-type specific and can only be used with one type of object (e.g., labels, titles, gridlines, etc.). In the attribute definitions that follow, the description of the attribute will indicate whether or not an object ID, series ID, and/or group ID is recommended or required with SetGraphAttr() or GetGraphAttr(). Some attributes are only applicable to specific graph types. Look for these legends with each attribute description to determine if an object ID, series ID, or group ID is required and to determine the graph types to which the attribute is applicable:

Usage

ObjectID

SeriesID

GroupID

GraphTypes

Requirements:

Object Type or No

Yes, No, or Optional

Yes, No, or Optional

List of GraphTypes where the attribute can be used

 

When a series ID is required, your application must guarantee the existence of the series object being modified using one of these:

 

1.

DrawTheGraph(). Once a chart is drawn, you can get/set the attributes of all visible series objects.

 

2.

CreateRisers(). If you want to set the attribute of a series object before drawing, you can force the creation of series objects by calling this function.

 

3.

DryRunTheGraph(). Creates detection nodes and all series objects but it does not actually draw anything to a DC.

NOTE:

PGSDK only saves as much series information as was used for the last screen draw. For example, a chart with four series is saved in a .3TF template file (using Save_TIFFGraph()). When the chart is loaded from the template, assume you want to set attributes for series five and six. Because the memory for these objects does not yet exist, any calls to SetGraphAttr() using a series greater than four will fail. PGSDK creates the memory when it draws the chart, but it is too late to modify a series 5/6 attribute at the point of screen output. To resolve this problem, use CreateRisers() to allocate memory for series five and six. After CreateRisers() is called, you may use SetGraphAttr() to assign attributes to these new series before screen output.

Also See:

PGSDK Programmer's Manual if you need more information about setting up and using PGSDK.