Series: Labels

  • 4 minutes to read

Labels can accompany series points to provide various additional information about them.

Series label

Use the setLabel method to customize settings specifying the content, position and appearance of series point labels. Note that series label settings depend on the series type.

The following table lists series and the corresponding label types:

Series type Label type
PieSeries PieSeriesLabel
DonutSeries PieSeriesLabel
AreaSeries MarkerSeriesLabel
StackedAreaSeries MarkerSeriesLabel
FullStackedAreaSeries MarkerSeriesLabel
StepAreaSeries MarkerSeriesLabel
BarSeries BarSeriesLabel
StackedBarSeries StackedBarSeriesLabel
FullStackedBarSeries StackedBarSeriesLabel
FullStackedBarSeries StackedBarSeriesLabel
FullStackedBarSeries StackedBarSeriesLabel
PointSeries MarkerSeriesLabel
BubbleSeries BubbleSeriesLabel
LineSeries MarkerSeriesLabel
StepLineSeries MarkerSeriesLabel
ScatterLineSeries MarkerSeriesLabel
CandleStickSeries FinancialSeriesLabel
StockSeries FinancialSeriesLabel

This guide shows the main customization scenarios.

How to: Format series labels

The following code snippet demonstrates how to specify a Point series point label pattern:

MarkerSeriesLabel label = new MarkerSeriesLabel();
label.setTextPattern("{A$tb}: {V$.0f}°C");

The setTextPattern method allows you to modify label text for a series.

In the code above, series label placeholders (A and V) specify a series point value that should be added to a label. The following label placeholders are available:

Placeholder Description
{S} Displays a series name.
{A} Displays a series point argument.
{L} Displays a pie series point label.
{V} Displays a series point value.
{VP} Displays a series point value as percentages.
{W} Displays a Bubble series point weight.
{O} Displays a financial series point open value.
{H} Displays a financial series point high value.
{L} Displays a financial series point low value.
{C} Displays a financial series point close value.
{HV} Displays a range bar series point max value.
{LV} Displays a range bar series point min value.

These values can be formatted using default format strings after the $ sign. For example, in the {VP$#.##} string, VP is a placeholder, $ is a format string separator, and #.## is a format string.

How to: Use a series labels text provider

If you need extra customization, for example, to calculate values shown by a label, write code to develop a class that inherits the series label text provider interface:

BarSeriesLabel label = new BarSeriesLabel();
label.setTextProvider(new BarSeriesLabelTextProvider());

// The series label text provider implementation.
private static class BarSeriesLabelTextProvider implements SeriesLabelTextProvider{
    private DecimalFormat mDecimalFormat = new DecimalFormat("#M");
    public String getText(SeriesLabelValuesBase seriesLabelValues) {
        return mDecimalFormat.format(((SeriesLabelValues)seriesLabelValues).getValue()/1000000);

Use the following symbols to implement a series label text provider:

Symbol Description
SeriesLabelTextProvider The interface that should be implemented by the class providing labels' text for the SeriesBase class descendant object.
SeriesLabelTextProvider.getText(SeriesLabelValuesBase) Formats the specified series label.
PieSeriesLabelValues Provides values available to build a pie series' label text.
SeriesLabelValues Provides values available to build a common Cartesian series' label text.
StackedSeriesLabelValues Provides values available to build a stacked series' label text.
FinancialSeriesLabelValues Provides values that configure the financial series's label text.

How to: Customize series labels' appearance

You can customize labels' appearance like any other chart elements' appearance.

Customized label text

See this code snippet to learn how to change this label text's appearance.

PieSeriesLabel label = new PieSeriesLabel();
PieSeriesLabelStyle style = new PieSeriesLabelStyle()
TextStyle textStyle = new TextStyle();
textStyle.setPaintFlags(Paint.ANTI_ALIAS_FLAG );

Symbols that are used to customize a label's text.

Symbol Description
PieSeriesLabelStyle Stores the Pie series label appearance settings.
SeriesLabelStyle The storage of the series label appearance settings.
TextElementStyleBase.setTextStyle(TextStyle) Specifies the chart element's text style.
TextStyle The text appearance parameters' storage.