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

18.7 CChart Example

The CChart example that is included in the Objective Chart kit shows how SRGCompoundDisplay is used and how a customized chart can be built from sub-components.

The relevant portions of the OnNewDocument() function are shown below. Some additional style settings have been added for illustrative purposes. Additional comments have been inserted to clarify various portions of the code.

Here the relationship between the two y-axes is established. First, the display is told that there is a correlation.

Then the conversion ratio between the right and left axes is specified. Note that setting this ratio to zero will invoke a special function that can be overridden to do more complex conversion. (For example, temperature conversion between degrees Celsius and degrees Fahrenheit.)

This code sets ups the display. Note that the display has a deferred draw setting. This ensures that its final graphic output is generated after all the other items (grids, etc.) are drawn. It is also possible do tell this item not to defer drawing and defer all the grid lines. That way the grids will be shown on top of the data.

The next four sections create and register labels that are used to annotate the four axes. Note how the font size of last label is adjusted to create a title for the chart. Labels that are displayed on the sides of the chart are oriented to read vertically so that they take up far less space. SetParent() is called because GetAnnotation() requires the parent SRGraph object's country code.

The single compound component with all its sub-components is placed onto the SRGraph m_ComponentList.

This code creates the chart in Figure 140.

Figure 140: Compound Chart



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.