An Axis Label is the text displayed along the axis. If the AutoLayout property of the chart is set to true, XAxisLabels and YAxisLabels are created automatically based on the given data. An Axis has LabelListFormat property based on which the Axis Labels are displayed. For setting LabelListFormat please refer to Java DateTime format strings and Numeric format strings. There are two types of Axis Labels:
XAxisLabel is text that gets displayed along with x-axis. The XAxisLabel can be rotated at different angles. The position of the label can be set using the XAxisLabelPosition class. The default value of XAxisLabelPosition enumeration is BelowXAxis.
- DateTimeXAxisLabel
- DateTimeXAxis use DateTimeXAxisLabel to display the text along the XAxis.
The below code shows how to add a DateTimeXAxisLabel to a DateTimeXAxis:
[Java] DateTimeXAxis xAxis = new DateTimeXAxis(); Calendar p0=Calendar.getInstance(); p0.set(2008,0,1); Calendar p1=Calendar.getInstance(); p1.set(2008,1,1); Calendar p2=Calendar.getInstance(); p2.set(2008,2,1); Calendar p3=Calendar.getInstance(); p3.set(2008,3,1); xAxis.getLabels().add(new DateTimeXAxisLabel("Tues", p0)); xAxis.getLabels().add(new DateTimeXAxisLabel("Wednes", p1)); xAxis.getLabels().add(new DateTimeXAxisLabel("Thurs", p2)); xAxis.getLabels().add(new DateTimeXAxisLabel("Fri", p3));
- IndexedXAxisLabel
- IndexedXAxis use IndexedXAxisLabel to display the text along the XAxis.
The below code shows how to add an IndexedXAxisLabel to an IndexedXAxis:
[Java] IndexedXAxis xAxis = new IndexedXAxis(); xAxis.getLabels().add(new IndexedXAxisLabel("Q1", 0)); xAxis.getLabels().add(new IndexedXAxisLabel("Q2", 1)); xAxis.getLabels().add(new IndexedXAxisLabel("Q3", 2)); xAxis.getLabels().add(new IndexedXAxisLabel("Q4", 3));
- NumericXAxisLabel
- NumericXAxis use NumericXAxisLabel to display text along the XAxis.
The below code shows how to add a NumericXAxisLabel to a NumericXAxis:
[Java] NumericXAxis xAxis = new NumericXAxis(); xAxis.getLabels().add(new NumericXAxisLabel("1", 10)); xAxis.getLabels().add(new NumericXAxisLabel("2", 20)); xAxis.getLabels().add(new NumericXAxisLabel("3", 30)); xAxis.getLabels().add(new NumericXAxisLabel("4", 40));
- PercentageXAxisLabel
- PercentageXAxis use PercentageXAxisLabel to display the text along the XAxis. It displays the text in percentage format.
The below code shows how to add a PercentageXAxisLabel to a PercentageXAxis:
[Java] PercentageXAxis xAxis = new PercentageXAxis(); xAxis.getLabels().add(new PercentageXAxisLabel("10%",10)); xAxis.getLabels().add(new PercentageXAxisLabel("20%",20)); xAxis.getLabels().add(new PercentageXAxisLabel("30%",30)); xAxis.getLabels().add(new PercentageXAxisLabel("40%",40));
- DateTimeYAxisLabel
- DateTimeYAxis use DateTimeYAxisLabel to display the text along the YAxis.
The below code shows how to add a DateTimeYAxisLabel to a DateTimeYAxis:
[Java] DateTimeYAxis yAxis = new DateTimeYAxis(); Calendar p0=Calendar.getInstance(); p0.set(2008,0,1); Calendar p1=Calendar.getInstance(); p1.set(2008,1,1); Calendar p2=Calendar.getInstance(); p2.set(2008,2,1); Calendar p3=Calendar.getInstance(); p3.set(2008,3,1); yAxis.getLabels().add(new DateTimeYAxisLabel("Tues", p0)); yAxis.getLabels().add(new DateTimeYAxisLabel("Wednes", p1)); yAxis.getLabels().add(new DateTimeYAxisLabel("Thurs", p2)); yAxis.getLabels().add(new DateTimeYAxisLabel("Fri", p3));
- IndexedYAxisLabel
- IndexedYAxis use IndexedYAxisLabel to display the text along the YAxis.
The below code shows how to add an IndexedYAxisLabel to an IndexedYAxis:
[Java] IndexedYAxis yAxis = new IndexedYAxis(); yAxis.getLabels().add(new IndexedYAxisLabel("Q1", 0)); yAxis.getLabels().add(new IndexedYAxisLabel("Q2", 1)); yAxis.getLabels().add(new IndexedYAxisLabel("Q3", 2)); yAxis.getLabels().add(new IndexedYAxisLabel("Q4", 3));
- NumericYAxisLabel
- NumericYAxis use NumericYAxisLabel to display text along the YAxis.
The below code shows how to add a NumericYAxisLabel to a NumericYAxis:
[Java] NumericYAxis yAxis = new NumericYAxis(); yAxis.getLabels().add(new NumericYAxisLabel("1", 10)); yAxis.getLabels().add(new NumericYAxisLabel("2", 20)); yAxis.getLabels().add(new NumericYAxisLabel("3", 30)); yAxis.getLabels().add(new NumericYAxisLabel("4", 40));
- PercentageYAxisLabel
PercentageYAxis use PercentageYAxisLabel to display the text along the YAxis. It displays the text in percentage format.
The below code shows how to add a PercentageYAxisLabel to a PercentageYAxis:
[Java] PercentageYAxis yAxis = new PercentageYAxis(); yAxis.getLabels().add(new PercentageYAxisLabel("10%",10)); yAxis.getLabels().add(new PercentageYAxisLabel("20%",20)); yAxis.getLabels().add(new PercentageYAxisLabel("30%",30)); yAxis.getLabels().add(new PercentageYAxisLabel("40%",40));