Point Labeling Tools in 0.5.1 2


Point Labeling Tools in 0.5.1

Two new features for labeling data have been added to Androidplot in 0.5.1:

PointLabelFormatter

First, the LineAndPointFormatter has been updated to support drawing text strings above the points themselves.  Using this functionality is as simple as passing in an instance of PointLabelFormatter to your addSeries calls: And here's what it looks like: For those not wanting to use PointLabelFormatter you'll notice that the old 3 argument version of addSeries has been deprecated.  All you need to do is pass in null: For the time being you'll need to explicitly cast this null to PointLabelFormatter to resolve the ambiguity between the new 4 argument version of addSeries and an older, deprecated version.

PointLabeler

While PointLabelFormatter provides a convenient solution to those wanting to label every point in a series, this functionality is rather limited.  Those who need more control can leverage the changes to LineAndPointRenderer.setPointLabeler(PointLabeler) to register a custom PointLabeler.  It's important to note that you use PointLabeler in conjunction with a PointLabelFormatter; if you passed in null as shown above, then no matter what you do in your custom PointLabeler, no labels will appear.  Here's a simple example that uses a custom PointLabeler to display even numbered indexes: Which gives us this:  

Leave a comment

Your email address will not be published. Required fields are marked *

2 thoughts on “Point Labeling Tools in 0.5.1