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

2.9 How a Chart is Constructed

The creation, configuration, and display of any Objective Chart involves the four basic steps discussed in the following sections.

2.9.1 Create an SRGraph Object

The foundation on which an Objective Chart is built is a single object of the SRGraph (StingRay Graph) class. This object manages the lists of components and data objects to be displayed. The SRGraph object can be stored anywhere within the program. Usually it is defined as a member of a document, view, or dialog class, but it can be stored in a global variable.

The initially empty SRGraph object must be configured before it can do anything useful. Setup for the chart is usually performed in the OnNewDocument(), OnInitialUpdate(), OnInitDialog(), or constructor of the class containing or displaying the chart.

2.9.2 Create and Configure Components

You create the individual components by constructing them on the heap using the new statement. They may be used as-is or you can modify the component style settings to change the appearance of the panel's background, border, shadow, and foreground. You can position each component on the screen by specifying its bounding rectangle. Several measurement modes are provided for flexibility.

After the component has been configured, you can place it on the component list by calling the SRGraph::AddComponent() function. The list may hold one component or many components.

The display component, SRGraphDisplay, is the workhorse of Objective Chart. The display component handles the drawing of the axes, labels, and data items for all the available graph and axis types. In addition to the style settings common to all components, the display component has special settings to select the chart type, axis type, axis scaling (logarithmic or linear), and axis limits (autoscaled or fixed).

2.9.3 Add Data Objects

In addition to its component list, the SRGraph object stores the data to be plotted. The details of the data storage structures are discussed in Chapter 8, "Data Storage Models."

Conceptually, the data values are stored in SRGraphData objects arranged in a two dimensional array. A data value, dValue, can be assigned to a specific element (row, column) of this array by calling SRGraph::SetValue(column, row, dValue).

In addition to the data value, SRGraphData contains a style member and a list of annotations. For many chart types, the style member determines the appearance of the line, wiget, bar, pie wedge, or other item representing the data object on the screen. The annotations are text strings that may be used for axis labels or chart tips for the data items.

2.9.4 Call DrawComponentList

Once the chart has been configured, it is ready to draw itself. In the view's OnDraw() function or the dialog control's OnPaint(), call SRGraph::DrawComponentList() passing pointers to a device context and a CWnd-object on which the graph is to be drawn. The SRGraph object iterates through its component list asking each component to draw itself. Because components are drawn in their order in the list, the first components on the list may be overwritten by the components that follow.

After the chart is displayed, you can add new components, change style settings on existing components, and add or update data values. The next time OnDraw() or OnPaint() is processed, the chart appears in its modified form. Any Objective Chart is dynamic in this sense.



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.