Skip to main content
Version: 5.5

Subtitle

A subtitle is a second title placed under the main title, by default.

To get, change and apply own properties, you can invoke the set and get methods, as following:

// sets the text of subtitle
chart.getOptions().getSubtitle().setText("My subtitle of chart");
// enables the subtitle and setting to use red color for text
chart.getOptions().getSubtitle().setDisplay(true);
chart.getOptions().getSubtitle().setColor("red");

IsColor color = chart.getOptions().getSubtitle().getColor();
boolean display = chart.getOptions().getSubtitle().isDisplay();

The defaults values are set in global defaults options, see default global title options.

The following are the attributes that you can set:

NameTypeScriptableDescription
alignElementAlignYesAlignment of the subtitle.
colorString - IsColorYesColor of text of the subtitle.
See default colors.
displaybooleanYesIf true, the subtitle is shown.
fontIsFontYesFont of subtitle text. The default value is the global font with the style set to FontStyle.BOLD.
See Font.
fullSizebooleanYesMarks that this box should take the full width/height of the canvas (moving other boxes).
paddingPaddingYesNumber of pixels to add above and below the subtitle text.
See padding documentation for more details.
positionPositionYesPosition of subtitle.

Scriptable

Subtitle also accepts a callback, for some of above attributes, which is called at runtime and that takes the context as single argument, see here the details, which is representing contextual information and chart instance.

// get subtitle
Subtitle subtitle = chart.getOptions().getSubtitle();
// sets callback
subtitle.setPadding(new PaddingCallback<ChartContext>(){

@Override
public PaddingItem invoke(ChartContext context){
PaddingItem padding = new PaddingItem();
// your logic
return padding;
}
});

The following option can be set by a callback:

NameCallbackReturned types
alignElementAlignCallback<ChartContext>ElementAlign
colorColorCallback<ChartContext>String - IsColor
displaySimpleDisplayCallback<ChartContext>boolean
fontFontCallback<ChartContext>FontItem
fullSizeFullSizeCallback<ChartContext>boolean
paddingPaddingCallback<ChartContext>PaddingItem
positionPositionCallback<ChartContext>Position