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;

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.

Hiding or Moving Overlapping Labels

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);