Previous | Next
Tutorial 3 - Chart Paging
If the data source for your Chart contains more data than can legibly displayed on one Chart screen you may wish to divide the Chart into pages that can be leafed through. This can be achieved via the Chart Editor or programmatically.
See the VB6 Paging demo for a working example of this tutorial, "Examples\Visual Basic\Visual Basic 6\Paging\PageProject1.vbp".
Paging with the Chart Editor
Page sizes may be defined with the Chart Editor. It will still be necessary to add paging buttons or the ChartPageNavigator component to your project or you could make the Chart Editor available at runtime to allow users to change pages with the Editor.
At design time, select the Paging page in the Chart Editor.
In the Points per Page: box, type (or scroll to) the number of Series points you wish to see on the Chart page. If you're coding the data values for the Series, the navigation buttons will not be highlighted until you run the project, populate the Series and show the Chart Editor at runtime. If you are connected to an ODBC datasource you should see paging take effect immediately at design time.
To access paging properties via the chart editor at runtime use ShowEditor.
The ChartPageNavigator component offers easy intuitive Chart page navigation, similar to existing navigators for database recordsets.
Set the Navigator's Chart property to the TeeChart you wish to Page.
ChartPageNavigator1.Chart = TChart1
Paging by code
Paging properties and methods are available via the IPage interface.
Steps required to add paging to your Chart:
- Define Points per page
Use MaxPointsPerPage to define the number of points to display on each page. e.g. TChart1.Page.MaxPointsPerPage = 10
- Add Navigation buttons to the Chart's Form (if not using the ChartPageNavigator).
Example: First Page
TChart1.Page.Current = 0
Advance a page
Goto previous page
With TChart1 .Page.Current = .Page.Count End With
- Decide what to do with the last page.
The last page is unlikely to have exactly the correct number of points to match the point quantity in the other Chart pages. You may choose to Scale the Last page which will 'best fit' the remaining points to the page, adjusting the axis scale accordingly, or you may treat the page as previous pages with the same number of points which may leave the last page rather empty if there are not many points for the page.
TChart1.Page.ScaleLastPage = False (default = True)
- Show the user a page number
The TChart OnPageChange event may be used to show the user the existing page number. Here using a Label to the Page number:
Label4.Caption = Str$(TChart1.Page.Current) " of " Str$(TChart1.Page.Count)
Print-previewing a multipage Chart
Multipage Charts may be print previewed whilst being navigated. Simply set the Previewer's Chart property to the Chart which you wish to view then use the ChartPageNavigator component to page the Chart.
That's all for this tutorial ! The next tutorial deals with advanced Axis and Legend manipulation.
© 1998-2019 Steema Software SL. All rights reserved.