Difference between revisions of "Java for Android Tutorial 3"

From Steema Software Reference Wiki
Jump to: navigation, search
(Paging by code)
 
Line 66: Line 66:
 
</center>
 
</center>
 
----
 
----
© 1998-2014 Steema Software SL. All rights reserved.
+
© 1998-{{CURRENTYEAR}} Steema Software SL. All rights reserved.

Latest revision as of 12:08, 29 April 2016

Java android.png

Contents page
Previous | Next

Tutorial 3 - Chart Paging


If the data source for your Chart contains more data than can be legibly displayed on one Chart screen you may wish to divide the Chart into pages that can be leafed through. This can be achieved programmatically.


Paging by code

Paging properties and methods are available via the Page class.

Steps required to add paging to your Chart:

  1. Define Points per page

Use MaxPointsPerPage to define the number of points to display on each page. e.g.

tChart1.setMaxPointsPerPage := 10;
  1. Add Navigation buttons to the Chart's Form.

Example: First Page

tChart1.getPage().setCurrent(1);

Advance a page

tChart1.getPage().next();

Go to a previous page

tChart1.getPage().previous();

Last Page

tChart1.getPage().setCurrent(tChart1.getChart().getNumPages());
  1. 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 on the page.

tChart1.getPage().setScaleLastPage(false);   (default = True)


  1. 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 for the Page number:

jLabel1.setText(String.valueOf(tChart1.getPage().getCurrent())  " of "   String.valueOf(tChart1.getChart().getNumPages()));


That's all for this tutorial ! The next tutorial deals with advanced Axis and Legend manipulation.




PREVIOUS

NEXT


© 1998-2019 Steema Software SL. All rights reserved.