Customizing a Compound Display
Changing the Formatting
To change the number of digits or add text for units, call SetFormatString() for the axis scale. For example,
SRGDecimalScale* pDS=new SRGDecimalScale;
pDS->SetFormatString('' %6.3f'');
pDS->SetFormatString('' %g CM'');
Deriving Your Own Class for Custom Labels
To create non-uniformly spaced or other specific labels:
1. Derive your own class from SRGDecimalScale and override CreateLabels() to generate labels however you want.
2. Instantiate an object of your new scale class, configure it, and register it with the appropriate axis manager.
Avoiding Overlapping Labels
Setting Resolution of Axis Labels
To avoid overlapping or “too close together” labels, set the resolution of the axis labels. For numeric axes, the resolution value is the difference between label values in axis units. For index and group scales, the resolution is a skip factor (2=every other annotation is displayed).
SRGDecimalScale* pDS=new SRGDecimalScale;
SRGIndexScale* pIS=new SRGIndexScale;
Set SetCheckOverlaps(TRUE) for the label block in your setup of the scale component.
Hiding or Moving Overlapping Labels
You can choose to hide the overlapping labels or to move them. For example,
SRGDecimalScale* pDS=new SRGDecimalScale;
pDS->SetResolution(0.1); // auto scale the indices
pCD->SetXLabelA(pDS); // this sets up all the axis scales.
Alternatively, you can rotate the labels to 45 or 90 degrees to avoid overlap.
SRGDecimalScale* pDS=new SRGDecimalScale;
Adding a Title for the Y-Axis
To add a Y-Axis title, add an SRGraphLabel as a title for the YAxisA.
SRGraphLabel* pL=new SRGraphLabel;
pL->SetParent(&m_Graph); // required for set annotation
Creating a Chart with 2 Y-Axes
Chart with One Display but Two Y-Axes
To create a chart with one display but two y-axes showing different units of the same variable (like the CChart sample):
1. Configure scales, tick marks, and grid lines (if desired) for both y-axes and at least one x-axis. (Only one axis should have a display component.)
2. Specify that the axes are related.
3. Define the relationship.
a. If the relationship is a simple multiplicative conversion, use
b. If a more complex formula is required, use
to override CalcYRelationShip().
This function accepts a value from the master (left) axis as a parameter and returns a value for the slave (right) axis.
Chart with Two Distinct Variable Types and Two Distinct Axes
To create a chart with two distinct variable types and two distinct axes:
1. Configure both y-axes and one x-axis.
a. Setup a display component for both y-axes. Of course, both displays must have similar styles. (In particular, they must have the same x-axis scale type and range.)
b. Set the y-axis ranges, if desired.
2. Set the data scope for each display. For example,
pD->SetScope(-1,-1,1,1); // data from group 1
3. Specify that the axes are not related (the default).