Labeling Wedges of a Pie Chart
Pie wedge labels display the data value and percentage of the total by default. A variety of other choices are available. The trick is to set the label style for each data item. In the loop in which the data are added to the graph, set the annotations and the desired label style. For example,
m_Graph.GetGroup(g)->GetIndex(x)->GetStyle()-> SetLabelStyle(CX_LABEL_TEXT);
The various label style choices are described below:
|
Wedge label style |
Description |
|
CX_LABEL_NONE |
|
|
CX_LABEL_AUTOMATIC |
Dynamic labels uses an appropriate label style from one of the label styles below. |
|
CX_LABEL_VALUE |
Data value |
|
CX_LABEL_PERCENT |
Data value as % of total |
|
CX_LABEL_TEXT |
Data object’s annotation |
|
CX_LABEL_VALUE_PERCENT |
Combination of above |
|
CX_LABEL_TEXT_VALUE |
|
|
CX_LABEL_TEXT_PERCENT |
|
|
CX_LABEL_TEXT_VALUE_PERCENT |
|
To explode a pie wedge from the pie:
-
Call SetHighlight() on the style member of the data object:
m_Graph.GetSafeData(index,group)->GetStyle()-> SetHighlight(CX_HIGHLIGHT_MEDIUM);
-
The highlight styles explode the wedge from the pie. CX_HIGHLIGHT_SMALL, CX_HIGHLIGHT_MEDIUM or CX_HIGHLIGHT_AUTOMATIC, and CX_HIGHLIGHT_LARGE displace the wedge by 15%, 20%, and 30% of the pie’s radius, respectively.
To place wedge labels inside of pie (instead of surrounding it), call SetObjectInsideView(TRUE) on the display’s style.
pDisplay->GetStyle()->SetObjectInsideView(TRUE);
To hide the labels of small wedges, specify a size limit using SetUseMaxScale(TRUE) and SetMinRangeX(). Data values (wedges) smaller than this limit are not labeled. The limit can be an absolute value or a percentage of the total of values in the pie. Negative values between 0 and -100 are interpreted as percentages.
pS->SetUseMaxScale(TRUE);
pD->SetMinRangeX(600.); // don't label wedges less than 600
or
pD->SetMinRangeX(-10.); // don't label wedges that are less than
// 10% of total






