Objective Chart : PART II Programmer’s Guide : Chapter 23 Data Tagging System : Using Data Tags
Using Data Tags
NOTE >> Currently the tagging system is implemented only for the graph types that require only one data object per displayed item (e.g., Line, VBar, HBar, etc.).
Selecting a Persistence Model
The first step in data tagging system is to select a persistence model for the generated labels.
To select a persistence model, call SRGraphStyle::SetTagModel() for the style member of the graph object with one of the following symbols:
CX_TAG_MODEL_AUTOMATIC = CX_TAG_MODEL_LOCAL
CX_TAG_MODEL_PERSISTENT
CX_TAG_MODEL_BLOCKED
For example,
 
m_Graph.GetStyle()->SetTagModel(CX_TAG_MODEL_LOCAL);
Drawing a Line From Data to Its Displaced Tag
To draw a line from the data item to its displaced tag (blocked model only), call SRGraphStyle::SetLinkTags(TRUE). For example,
 
pD->GetStyle()->SetLinkTags(TRUE);
For each data object to be tagged, styles can be applied to specify the appearance of the tag and its border.
Selecting the Tag’s Content
To select the content of the tag, call SRGraphStyle::SetLabelStyle() with one of these symbols:
CX_LABEL_AUTOMATIC = CX_LABEL_NONE
CX_LABEL_VALUE
CX_LABEL_TEXT
CX_LABEL_TEXT_VALUE
For example,
 
SRGraphStyle* pDStyle = m_Graph.GetSafeData(n,g)->GetStyle();
pDStyle->SetLabelStyle(CX_LABEL_TEXT);
Selecting the Tag’s Outline Style
To select the outline style of the tag, call SRGraphStyle::SetTagOutlineStyle() with one of these symbols:
CX_TAG_OUTLINE_NONE = CX_TAG_OUTLINE_AUTOMATIC
CX_TAG_OUTLINE_BOX
CX_TAG_OUTLINE_ELLIPSE
CX_TAG_OUTLINE_FLASH
CX_TAG_OUTLINE_POLYGON //(not yet implemented)
CX_TAG_OUTLINE_CUSTOM // (not yet implemented)
For example,
 
pDStyle->SetTagOutlineStyle(CX_TAG_OUTLINE_BOX);
Setting Tag Position Relative to the Data Item
To set the position of the tag relative to the data item (and the collision avoidance vector for the blocked model), call SRGraphStyle::SetTagPosition() with one of these symbols:
CX_TAG_POSITION_LEFT
CX_TAG_POSITION_LEFTABOVE
CX_TAG_POSITION_ABOVE
CX_TAG_POSITION_RIGHTABOVE
CX_TAG_POSITION_RIGHT
CX_TAG_POSITION_RIGHTBELOW
CX_TAG_POSITION_BELOW
CX_TAG_POSITION_LEFTBELOW
CX_TAG_POSITION_CENTERED
For example,
 
pDStyle->SetTagPosition(CX_TAG_POSITION_ABOVE);
Setting Font Size for Labels
To set the font size for the labels, call SRGraphStyle::SetTagFontSize() with one of these symbols:
CX_TAG_FONT_NORMAL
CX_TAG_FONT_SMALL // (8 points)
CX_TAG_FONT_LARGE // (10 points)
CX_TAG_FONT_CUSTOM // override GetCustomTagFontSize()
For example,
 
pDStyle->SetTagFontSize(CX_TAG_FONT_LARGE);
Setting Font and Tag Frame Orientation
To set the font and tag frame orientation, call SRGraphStyle::SetTagOrientation() with one of these symbols:
CX_TAG_ORIENTATION_ZERO
CX_TAG_ORIENTATION_45
CX_TAG_ORIENTATION_90
CX_TAG_ORIENTATION_135
CX_TAG_ORIENTATION_180
CX_TAG_ORIENTATION_225
CX_TAG_ORIENTATION_270
CX_TAG_ORIENTATION_315
For example,
 
pDStyle->SetTagOrientation(CX_TAG_ORIENTATION_ZER0);
Data Tag Example
The use of these styles is illustrated in the code segment below, which labels the four curves (groups) by tagging the first data object in each group.
 
SRGraphDisplay* pD=new SRGraphDisplay;
SRGraphStyle* pS=pD->GetStyle();
pD->SetMeasurement(SRGraphComponent::PERCENT);
pD->SetRect(-1,15,-1,85
pS->SetGraphStyle(CX_GRAPH_LINE);
pS->SetAxisStyle(CX_AXIS_AUTOMATIC);
m_Graph.AddComponent((SRGraphComponent *)pD);
 
// select a persistence model for tags
m_Graph.GetStyle()->SetTagModel(CX_TAG_MODEL_LOCAL);
 
// loop setting data values and annotations, 4 groups
[not shown]
 
// loop setting tag styles
SRGraphStyle* pDStyle;
for(int g=0; g<4; g++)
{
// label first data object in each group
pDStyle = m_Graph.GetSafeData(0,g)->GetStyle();
// with the data object’s annotation
pDStyle->SetLabelStyle(CX_LABEL_TEXT);
// use a rectangular frame
pDStyle->SetTagOutlineStyle(CX_TAG_OUTLINE_BOX);
// and a large font
pDStyle->SetTagFontSize(CX_TAG_FONT_LARGE);
pDStyle->SetTagColor(CXCLR_CYAN);
// place the tag above the data item
pDStyle->SetTagPosition(CX_TAG_POSITION_ABOVE);
// make ‘em horizontal
pDStyle-> SetTagOrientation(CX_TAG_ORIENTATION_ZER0);
}