Controlling Tick Marks and Grid Lines
The appearance of axis labels, tick marks, and grid lines is controlled by the SRGraphStyle member of the SRGraphDisplay component.
To turn on or off the display of tick marks and grid lines, use the SRGraphStyle::SetShowXTicks() and SRGraphStyle::SetShowXGrid() and the equivalent Y or Z functions.
The code snippet below illustrates how to turn off the drawing of grid lines:
// create a display component
SRGraphDisplay* pD=new SRGraphDisplay;
SRGraphStyle* pS=pD->GetStyle();
// set the graph and axis types
pS->SetGraphStyle(CX_GRAPH_XYSCATTERG_EX);
pS->SetAxisStyle(CX_AXIS_AUTOMATIC);
// disable horiz. and vertical grid lines
pS->SetShowXGrid(FALSE);
pS->SetShowYGrid(FALSE);
m_Graph.AddComponent((SRGraphComponent *)pD);
Grid line color is set by SRGraphStyle::SetGridColor().
SRGraphDisplay* pD=new SRGraphDisplay;
pD->GetStyle()->SetGridColor(CXCLR_GRAY20);
Normally, the grid is drawn first and the data items overwrite the grid. To display a grid on top of the data, call SRGraphStyle::SetGridOrder(FALSE).
SRGraphDisplay* pD=new SRGraphDisplay;
pD->GetStyle()->SetGridOrder(FALSE);
To change the length of tick marks, call SRGraphComponent::SetTickSize(). The units depend on the measurement mode — see SRGraphComponent::SetSizeDefaults() in the source code.
SRGraphDisplay* pD=new SRGraphDisplay;
pD->SetMeasurement(SRGraphComponent::PERCENT);
pD->SetRect(-1,10,-1,85);
pD->SetTickSize(1.5); // def=1.25 percent
To hide axis labels, tick marks, and gridlines, call SetShowIndices(0), SetShowGroups(0), or SetShowNumerals(0). As shown in Table 10, calling these functions turns off the generation of axis labels (and therefore tick marks and grid lines, too) for the indicated axis.
Function called |
Axis hidden |
SetShowIndices(0) |
Horizontal axis for classic styles |
SetShowGroups(0) |
Third axis for stage and platform styles |
SetShowNumerals(0) |
Vertical, numeric axis for classic styles |
For example, the following code turns off all markings for the horizontal axis.
SRGraphDisplay* pD=new SRGraphDisplay;
SRGraphStyle* pS=pD->GetStyle();
pS->SetGraphStyle(CX_GRAPH_VBAR);
pS->SetAxisStyle(CX_AXIS_AUTOMATIC);
// disable drawing of horizontal axis
pS->SetShowIndices(FALSE);