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

24.2 Aligning the Axes of Multiple Displays

Just like other Objective Chart components, multiple display components can be placed in a window using the SRGraphComponent::SetRect() function. SetRect() specifies the area that the component covers. However, it is often desirable to align the display axes rather than the component rectangles.

For example, several graphs plotting different variables during the same time period (or other independent variable) can be stacked one on top of the other. The horizontal axes of all the displays should be the same, but the y-axis labels may require different amounts of space. Therefore, the length of the horizontal axes may vary.

To align the axes of multiple displays, call SRGraphDisplay::SetDisplayRect(rectDisplay, TRUE)

SetDisplayRect() requires rectangle coordinates in pixels. Therefore, it is not compatible with the device independent measurement modes. Also, if the display window can be resized, the OnSize() handler is the logical place to set the rectangle.

The sample below shows the setup code from OnNewDocument(). It creates two display components that plot the same data with different graph types. The positioning of the components is deferred to the OnSize() member of the view class. In OnSize(), SetRect() places the component rectangles of the two displays, and SetDisplayRect() aligns the display rectangles by specifying the same left and right coordinates for both graphs. Note the use of SRGraph::GetComponentList() and GetComponent() to gain access to the display component.

If this sample is in an MDI application, OnSize() is not normally called by the framework after the document (graph) is created. So we call OnSize() from the view's OnInitialUpdate() function.



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.