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''); |
or
pDS->SetFormatString('' %g CM''); |
To create non-uniformly spaced or other specific labels:
Derive your own class from SRGDecimalScale and override CreateLabels() to generate labels however you want.
Instantiate an object of your new scale class, configure it, and register it with the appropriate axis manager.
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; pDS->SetResolution(0.5); |
or
SRGIndexScale* pIS=new SRGIndexScale; PDS->SetResolution(4); |
Set SetCheckOverlaps(TRUE) for the label block in your setup of the scale component.
You can choose to hide the overlapping labels or to move them. For example,
SRGDecimalScale* pDS=new SRGDecimalScale; pDS->GetStyle()->SetAutoOrientation(FALSE); pDS->SetOrientation(0.); pDS->SetLabelSide(FALSE); pDS->SetResolution(0.1); // auto scale the indices pDS->SetLocationPoint(SRGraphLabel::TopCenter); pDS->SetCheckOverlaps(TRUE); pDS->GetStyle()->SetLabelStyle(CX_LABELBLOCK_MOVELABELS); // or CX_LABELBLOCK_HIDELABELS 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; pDS->GetStyle()->SetAutoOrientation(FALSE); pDS->SetOrientation(45.); pDS->SetLocationPoint(SRGraphLabel::MidRight); |
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 pL->SetAnnotation("Meters"); pCD->GetYAxisA()->RegisterTitle(pL); |
To create a chart with one display but two y-axes showing different units of the same variable (like the CChart sample):
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.)
Specify that the axes are related.
pCD->SetYRelationship(TRUE); |
Define the relationship.
a. | If the relationship is a simple multiplicative conversion, use pCD->SetYRatio(1.0/25.4); |
b. | If a more complex formula is required, use pCD->SetYRatio(0); 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. |
To create a chart with two distinct variable types and two distinct axes:
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. |
Set the data scope for each display. For example,
pD->SetScope(-1,-1,1,1); // data from group 1 pD->GetStyle()->SetRelIndex(TRUE); |
Specify that the axes are not related (the default).
pCD->SetYRelationship(FALSE); |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.