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

16.3 Defining Custom Chart Types and Axis Styles

Objective Chart styles are defined by a set of bit patterns and numbers generally held in an SRGraphStyle object. Whenever the chart is drawn, the styles used to define the appearance of a display or other component are run through a switch statement in the draw code. If at any time, an unknown style setting is found, then the standard classes invoke virtual functions to handle the new style. In the standard Objective Chart library, these virtual functions either ASSERT (debug build) or do nothing (release build).

When capabilities need to be added to the standard chart system, define a new style mask and override the relevant handler routines.

Once Objective Chart has invoked the custom style handing routine or chart extension function, it is the programmer's responsibility to define the operations that follow. These extension functions can only be considered as hooks into the standard system.

16.3.1 Chart Extension Routines

All of the styles for component fills, borders, and shadows may be extended. The chart data, axis, and label styles, as well as the position class may also be extended.

The handler routines for custom styles are:

In addition, the following routines contain graph-type dependencies that are not handled by the extension routines. Complete implementation of a new chart type may require changes to these routines as well.

16.3.2 Custom Graph - Axis Types

A custom graph type is implemented by defining a symbolic constant with a value of CX_GRAPH_USER or above (range 00c00000 to 00ff0000) and overriding the empty, virtual functions of SRGraphDisplay to draw the graph. Similarly, a new axis type is implemented by defining a symbolic constant of CX_AXIS_USER or above (range c0000000 to ff000000) and overriding other functions.

When setting up the chart in the application, instantiate an object of the derived display class and add it to the component list. Use the custom graph type in the call to SetGraphStyle() and the custom axis style with SetAxisStyle().

Customizations that require a new graph type often require a new axis type as well. Therefore, when defining a new graph type, the following functions must be overridden:

The purposes of the first four functions are described in a previous section.

SRGraphPosition::CalcUserDisplayPosition() is the important function that infers information about a point on the screen from the graph type and axis scaling parameters. It is required for data selection, zooming, and data dragging. SRGraphView::GetPosition() must be overridden to utilize the new graph position class.

Some of the other custom drawing routines may have to be overridden depending on the specific application requirements.

For a practical look at chart extensions, the ChartEx example that comes with Objective Chart shows how to build a custom two y-axis display with auto scaling features. The PlotterDlg sample demonstrates a simple application of these techniques.



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.