Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Objective Chart User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

17.3 Using Axis Scale Components

Using these classes, a chart can have as many as axes as are needed. The user must allot space for the axes as with other components.

SRGScaleBar adds a few variables and accessor functions to the base class, SRGDecimalScale. These new attributes are discussed below.

The m_nScaleType variable is of the enumerated type, SRGScaleType, which can have three values: VERTICAL, HORIZONTAL, and ANGLE. The VERTICAL type creates a typical y-axis, while the HORIZONTAL type indicates a typical x-axis. The ANGLE type allows an axis to be drawn at any angle. This variable can be set by calling SetScaleType().

If the scale type is HORIZONTAL or VERTICAL, the scale bar is drawn like other Objective Chart components— with a filled background, border, and shadow. If the m_bLabelSide is set— SetLabelSide(TRUE), the axis line is drawn on the bottom or left side of the component rectangle. Otherwise, the axis line is drawn on the top or right side. The starting and ending positions of the axis line are aligned with the appropriate corners of the display rectangle of the attached display component. If the graph style of the display is an isographic type, the starting and ending points are adjusted appropriately.

If the scale type is ANGLE, then no background fill, border, nor shadow is drawn by default. The arguments passed to the SetRect() function have a different meaning. In this case, the first two arguments indicate the x and y coordinates of the starting point of the axis and the last two arguments are the coordinates of the ending point. The specified values are converted to client coordinates according to the measurement mode, as for other components.

The axis line and tick marks are drawn by default. Drawing of the axis line and tick marks can be turned off by calling SetShowAxis(FALSE) and SetShowTick(FALSE), respectively. Tick marks are drawn in the frame color set by calling GetStyle()->SetFrameColor(). The axis can also draw grid lines on the attached display if the appropriate ShowXGrid or ShowYGrid style flag is set. To draw the tick marks and grid lines, SetLogTickPositions(TRUE) must be called to force the scale to create a tick list. The remaining members— m_nAxisWidth, m_AxisColor, and m_nAxisPenStyle— control the axis line's appearance.

For numeric axes, the axis limits are computed from the appropriate range in the attached display. The m_nConversionMode variable controls the conversion. The default value, NO_CONVERSION, uses the display's values with no conversion. If the mode is set to RATIO_CONVERSION – SetConversionMode(RATIO_CONVERSION), then the display's values are multiplied the constant m_dConvertRatio, specified by calling SetConversionRatio(). More complex mathematical conversions can be implemented by setting the mode to FUNC_CONVERSION and overriding the virtual function DoConversion (double dValue) to return the value computed from dValue.

For date scales, multiplicative conversions don't make sense. So SetConversionMode(FUNC_CONVERSION) and an override of DoConversion() should be generally used with SRGDateBar.

SRGGroupBar displays the annotations from the group headers (SRGraphDataList). SRGIndexBar displays the annotation from group 0 or the first group in the display's scope depending on whether SetRelIndex(TRUE) has been called. You can override CreateLabels() to modify this standard behavior. For example, SRGGroupBar could display annotations with a specified country code or SRGIndexBar could display the annotations from a specified group.

These axis-drawing components provide an alternate method for creating charts with multiple overlapping displays, in addition to compound displays and synchronized displays as in the SyncDisp sample. You can call SRGraphStyle::SetDisplayInfoOnly(TRUE) to keep the display from calling its own DrawLabels() function and create scale-bar objects to draw the axes instead. DrawLabels() usually adjusts the display rectangle to make room for the axes. This makes overlapping displays difficult, because the final display rectangle is not known until run time. When the functionality of DrawLabels() is replaced by scale bars, the display rectangle is not resized. Then the positions of the displays and axes can be specified at design time.

To create charts with overlapping displays using scale bars:

  1. Configure one or more display components with the same component rectangle and with SetDisplayInfoOnly(TRUE). Give all displays, except the first, the CX_NO_FILL fill style for a transparent background.

      SRGraphDisplay* pD2 = new SRGraphDisplay;
      SRGraphStyle* pS = pD2->GetStyle();
      pD2->SetMeasurement(PERCENT);
      pD2->SetRect(left, top, right, bottom); 
      pS->SetComponentFillStyle(CX_NO_FILL);
      pS->SetDisplayInfoOnly(TRUE);
      m_Graph.AddComponent(pD2);
      
  2. Configure and position as many scale bars as required.

      SRGScaleBar* pSB = new SRGScaleBar;
      pSB->SetMeasurement(CX_PERCENT);
      pSB->SetRect(0, top, left, bottom);
      pSB->GetStyle()->SetComponentFillStyle(CX_SOLID_FILL);
      pSB->GetStyle()->SetColor(CXCLR_CYAN);
      pSB->SetScaleType(VERTICAL);
      pSB->SetLogTickPositions(TRUE);
      pSB->SetResolution(1);
      pSB->SetXMargin(3);
      pSB->SetLabelSide(FALSE);
      pSB->SetLocationPoint(SRGraphLabel::MidRight);
      pSB->SetAxisWidth(4);
      pSB->SetAxisColor(RGB(0, 0, 0));
      pSB->SetShowAxis(TRUE);
      pSB->SetFormatString(_T(" %.1f C "));
      m_Graph.AddComponent(pSB);
      

The IndependentScale sample demonstrates the use of the axis bar classes with a display component that does not draw its own axes.



Previous fileTop of DocumentContentsNo linkNext file

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.