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:
Name | Type | Scriptable | Description |
---|---|---|---|
align | ElementAlign | Yes | Alignment of the subtitle. |
color | String - IsColor | Yes | Color of text of the subtitle. See default colors. |
display | boolean | Yes | If true , the subtitle is shown. |
font | IsFont | Yes | Font of subtitle 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 subtitle text. See padding documentation for more details. |
position | Position | Yes | Position 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:
Name | Callback | Returned types |
---|---|---|
align | ElementAlignCallback<ChartContext> | ElementAlign |
color | ColorCallback<ChartContext> | String - IsColor |
display | DisplayCallback<ChartContext> | boolean |
font | FontCallback<ChartContext> | FontItem |
fullSize | FullSizeCallback<ChartContext> | boolean |
padding | PaddingCallback<ChartContext> | PaddingItem |
position | PositionCallback<ChartContext> | Position |