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:
| Name | Type | Scriptable | Description |
|---|---|---|---|
| align | ElementAlign | Yes | Alignment of the title. |
| color | String - IsColor | Yes | Color of text of the title. See default colors. |
| display | boolean | Yes | If true, the title is shown. |
| font | IsFont | Yes | Font of title text. The default value is the global font with the style set to FontStyle.BOLD. See Font. |
| fullSize | boolean | Yes | Marks that this box should take the full width/height of the canvas (moving other boxes). |
| padding | Padding | Yes | Number of pixels to add above and below the title text. See padding documentation for more details. |
| position | Position | Yes | Position 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:
| Name | Callback | Returned types |
|---|---|---|
| align | ElementAlignCallback<ChartContext> | ElementAlign |
| color | ColorCallback<ChartContext> | String - IsColor |
| display | SimpleDisplayCallback<ChartContext> | boolean |
| font | FontCallback<ChartContext> | FontItem |
| fullSize | FullSizeCallback<ChartContext> | boolean |
| padding | PaddingCallback<ChartContext> | PaddingItem |
| position | PositionCallback<ChartContext> | Position |