Skip to main content
Version: 5.0

Title

A title is a name or words used to describe a chart.

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

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

IsColor color = chart.getOptions().getTitle().getColor();
boolean display = chart.getOptions().getTitle().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 title.
colorString - IsColorYesColor of text of the title.
See default colors.
displaybooleanYesIf true, the title is shown.
fontIsFontYesFont of title 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 title text.
See padding documentation for more details.
positionPositionYesPosition of title.

Scriptable

Title 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 title
Title title = chart.getOptions().getTitle();
// sets callback
title.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
displayDisplayCallback<ChartContext>boolean
fontFontCallback<ChartContext>FontItem
fullSizeFullSizeCallback<ChartContext>boolean
paddingPaddingCallback<ChartContext>PaddingItem
positionPositionCallback<ChartContext>Position