Axes Titles

Titles can be created on a chart's axes. They can be assigned, aligned and formatted according to the different properties supported by Title object. Axes Titles can be assigned via the Chart FX for Java designer properties list or you can create and control them programmatically.

All Axes titles you create, by default, are aligned at the center. For example, if you add the following code:


chart1.getAxisX().getTitle().setText("X-axis Title");
chart1.getAxisY().getTitle().setText("Y-axis Title");

You will get the following chart:

Axes Titles are attached to the Axis to which they belong. If the Y-axis gets moved to the right side of the chart (Far), the Y-axis Title will get moved there as well. If the X-axis is hidden, the X-axis Title will be hidden also.

You can create a multi-line title by including the newline character (\n) within the Title Text:


chart1.getAxisY().getTitle().setText("Unit Sales \n (In Millions)");