In This Topic
Titles give a description about what the chart is about. Titles are displayed on a single line. Therefore, text that does not fit on one line will be truncated. However, you can add multiple Titles to charts, plot areas and the XAxis and the YAxis. There are three different types of titles:
- Charts can have HeaderTitles and FooterTitles. HeaderTitles appear on top of the chart and FooterTitles appear at the bottom of the chart.
-
The below code shows how to add HeaderTitle and FooterTitle to a chart:
[Java]
Chart chart = new Chart(0, 0, 300, 200);
Title title1 = new Title("Header Title");
Title title2 = new Title("Footer Title");
chart.getHeaderTitles().add(title1);
chart.getFooterTitles().add(title2);
- Plot Areas can have TopTitles and BottomTitles. TopTitles appear on top of the Plot Area and BottomTitles appear at the bottom of the Plot Area.
-
The below code shows how to add TopTitles and BottomTitles to a plot area.
[Java]
Chart chart = new Chart(0, 0, 300, 200);
PlotArea plotArea = chart.getPrimaryPlotArea();
Title title1 = new Title("Top Title");
Title title2 = new Title("Bottom Title");
plotArea.getTopTitles().add(title1);
plotArea.getBottomTitles().add(title2);
- Axis titles describe what data on the XAxis and the YAxis represent.
-
The below code shows how to add Titles to the axes.
[Java]
Chart chart = new Chart(0, 0, 300, 200);
PlotArea plotArea = chart.getPrimaryPlotArea();
Title title1 = new Title("XAxis Title");
Title title2 = new Title("YAxis Title");
plotArea.getXAxes().getDefaultNumericXAxis().getTitles().add(title1);
plotArea.getYAxes().getDefaultNumericYAxis().getTitles().add(title2);
See Also