ChartAxisTitle

Inheritance: java.lang.Object

public class ChartAxisTitle

Provides access to the axis title properties.

To learn more, visit the Working with Charts documentation article.

Examples:

Shows how to set chart axis title.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);

 Chart chart = shape.getChart();
 ChartSeriesCollection seriesColl = chart.getSeries();
 // Delete default generated series.
 seriesColl.clear();

 seriesColl.add("AW Series 1", new String[] { "AW Category 1", "AW Category 2" }, new double[] { 1.0, 2.0 });

 // Set axis title.
 ChartAxisTitle chartAxisXTitle = chart.getAxisX().getTitle();
 chartAxisXTitle.setText("Categories");
 chartAxisXTitle.setShow(true);
 ChartAxisTitle chartAxisYTitle = chart.getAxisY().getTitle();
 chartAxisYTitle.setText("Values");
 chartAxisYTitle.setShow(true);
 chartAxisYTitle.setOverlay(true);
 chartAxisYTitle.getFont().setSize(12.0);
 chartAxisYTitle.getFont().setColor(Color.BLUE);

 doc.save(getArtifactsDir() + "Charts.ChartAxisTitle.docx");
 

Methods

MethodDescription
getFont()Provides access to the font formatting of the axis title.
getFormat()Provides access to fill and line formatting of the axis title.
getOrientation()Gets the orientation of the axis title text.
getOverlay()Determines whether other chart elements shall be allowed to overlap the title.
getRotation()Gets the rotation of the axis title in degrees.
getShow()Determines whether the title shall be shown for the axis.
getText()Gets the text of the axis title.
setOrientation(int value)Sets the orientation of the axis title text.
setOverlay(boolean value)Determines whether other chart elements shall be allowed to overlap the title.
setRotation(int value)Sets the rotation of the axis title in degrees.
setShow(boolean value)Determines whether the title shall be shown for the axis.
setText(String value)Sets the text of the axis title.

getFont()

public Font getFont()

Provides access to the font formatting of the axis title.

Examples:

Shows how to set chart axis title.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);

 Chart chart = shape.getChart();
 ChartSeriesCollection seriesColl = chart.getSeries();
 // Delete default generated series.
 seriesColl.clear();

 seriesColl.add("AW Series 1", new String[] { "AW Category 1", "AW Category 2" }, new double[] { 1.0, 2.0 });

 // Set axis title.
 ChartAxisTitle chartAxisXTitle = chart.getAxisX().getTitle();
 chartAxisXTitle.setText("Categories");
 chartAxisXTitle.setShow(true);
 ChartAxisTitle chartAxisYTitle = chart.getAxisY().getTitle();
 chartAxisYTitle.setText("Values");
 chartAxisYTitle.setShow(true);
 chartAxisYTitle.setOverlay(true);
 chartAxisYTitle.getFont().setSize(12.0);
 chartAxisYTitle.getFont().setColor(Color.BLUE);

 doc.save(getArtifactsDir() + "Charts.ChartAxisTitle.docx");
 

Returns: Font - The corresponding Font value.

getFormat()

public ChartFormat getFormat()

Provides access to fill and line formatting of the axis title.

Examples:

Shows how to use chart formating.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
 Chart chart = shape.getChart();

 // Delete series generated by default.
 ChartSeriesCollection series = chart.getSeries();
 series.clear();

 String[] categories = new String[] { "Category 1", "Category 2" };
 series.add("Series 1", categories, new double[] { 1.0, 2.0 });
 series.add("Series 2", categories, new double[] { 3.0, 4.0 });

 // Format chart background.
 chart.getFormat().getFill().solid(Color.darkGray);

 // Hide axis tick labels.
 chart.getAxisX().getTickLabels().setPosition(AxisTickLabelPosition.NONE);
 chart.getAxisY().getTickLabels().setPosition(AxisTickLabelPosition.NONE);

 // Format chart title.
 chart.getTitle().getFormat().getFill().solid(Color.yellow);

 // Format axis title.
 chart.getAxisX().getTitle().setShow(true);
 chart.getAxisX().getTitle().getFormat().getFill().solid(Color.yellow);

 // Format legend.
 chart.getLegend().getFormat().getFill().solid(Color.yellow);

 doc.save(getArtifactsDir() + "Charts.ChartFormat.docx");
 

Returns: ChartFormat - The corresponding ChartFormat value.

getOrientation()

public int getOrientation()

Gets the orientation of the axis title text.

Remarks:

The default value is ShapeTextOrientation.HORIZONTAL.

Examples:

Shows how to set orientation and rotation of chart and axis titles.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);
 Shape chartShape = builder.insertChart(ChartType.COLUMN, 400.0, 300.0);
 Chart chart = chartShape.getChart();

 chart.getTitle().setText("Sample Chart");
 chart.getTitle().setOrientation(ShapeTextOrientation.HORIZONTAL);
 chart.getTitle().setRotation(90);

 // Before setting title properties, make sure that this title will be displayed.
 chart.getAxisX().getTitle().setShow(true);
 chart.getAxisX().getTitle().setText("X Axis");
 chart.getAxisX().getTitle().setOrientation(ShapeTextOrientation.HORIZONTAL);
 chart.getAxisX().getTitle().setRotation(-90);

 doc.save(getArtifactsDir() + "Charts.TitleOrientation.docx");
 

Returns: int - The orientation of the axis title text. The returned value is one of ShapeTextOrientation constants.

getOverlay()

public boolean getOverlay()

Determines whether other chart elements shall be allowed to overlap the title. The default value is false .

Examples:

Shows how to set chart axis title.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);

 Chart chart = shape.getChart();
 ChartSeriesCollection seriesColl = chart.getSeries();
 // Delete default generated series.
 seriesColl.clear();

 seriesColl.add("AW Series 1", new String[] { "AW Category 1", "AW Category 2" }, new double[] { 1.0, 2.0 });

 // Set axis title.
 ChartAxisTitle chartAxisXTitle = chart.getAxisX().getTitle();
 chartAxisXTitle.setText("Categories");
 chartAxisXTitle.setShow(true);
 ChartAxisTitle chartAxisYTitle = chart.getAxisY().getTitle();
 chartAxisYTitle.setText("Values");
 chartAxisYTitle.setShow(true);
 chartAxisYTitle.setOverlay(true);
 chartAxisYTitle.getFont().setSize(12.0);
 chartAxisYTitle.getFont().setColor(Color.BLUE);

 doc.save(getArtifactsDir() + "Charts.ChartAxisTitle.docx");
 

Returns: boolean - The corresponding boolean value.

getRotation()

public int getRotation()

Gets the rotation of the axis title in degrees.

Remarks:

The range of acceptable values is from -180 to 180 inclusive.

Examples:

Shows how to set orientation and rotation of chart and axis titles.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);
 Shape chartShape = builder.insertChart(ChartType.COLUMN, 400.0, 300.0);
 Chart chart = chartShape.getChart();

 chart.getTitle().setText("Sample Chart");
 chart.getTitle().setOrientation(ShapeTextOrientation.HORIZONTAL);
 chart.getTitle().setRotation(90);

 // Before setting title properties, make sure that this title will be displayed.
 chart.getAxisX().getTitle().setShow(true);
 chart.getAxisX().getTitle().setText("X Axis");
 chart.getAxisX().getTitle().setOrientation(ShapeTextOrientation.HORIZONTAL);
 chart.getAxisX().getTitle().setRotation(-90);

 doc.save(getArtifactsDir() + "Charts.TitleOrientation.docx");
 

Returns: int - The rotation of the axis title in degrees.

getShow()

public boolean getShow()

Determines whether the title shall be shown for the axis. The default value is false .

Examples:

Shows how to set chart axis title.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);

 Chart chart = shape.getChart();
 ChartSeriesCollection seriesColl = chart.getSeries();
 // Delete default generated series.
 seriesColl.clear();

 seriesColl.add("AW Series 1", new String[] { "AW Category 1", "AW Category 2" }, new double[] { 1.0, 2.0 });

 // Set axis title.
 ChartAxisTitle chartAxisXTitle = chart.getAxisX().getTitle();
 chartAxisXTitle.setText("Categories");
 chartAxisXTitle.setShow(true);
 ChartAxisTitle chartAxisYTitle = chart.getAxisY().getTitle();
 chartAxisYTitle.setText("Values");
 chartAxisYTitle.setShow(true);
 chartAxisYTitle.setOverlay(true);
 chartAxisYTitle.getFont().setSize(12.0);
 chartAxisYTitle.getFont().setColor(Color.BLUE);

 doc.save(getArtifactsDir() + "Charts.ChartAxisTitle.docx");
 

Returns: boolean - The corresponding boolean value.

getText()

public String getText()

Gets the text of the axis title. If null or empty value is specified, auto generated title will be shown.

Remarks:

Use getShow() / setShow(boolean) option if you need to show the title.

Examples:

Shows how to set chart axis title.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);

 Chart chart = shape.getChart();
 ChartSeriesCollection seriesColl = chart.getSeries();
 // Delete default generated series.
 seriesColl.clear();

 seriesColl.add("AW Series 1", new String[] { "AW Category 1", "AW Category 2" }, new double[] { 1.0, 2.0 });

 // Set axis title.
 ChartAxisTitle chartAxisXTitle = chart.getAxisX().getTitle();
 chartAxisXTitle.setText("Categories");
 chartAxisXTitle.setShow(true);
 ChartAxisTitle chartAxisYTitle = chart.getAxisY().getTitle();
 chartAxisYTitle.setText("Values");
 chartAxisYTitle.setShow(true);
 chartAxisYTitle.setOverlay(true);
 chartAxisYTitle.getFont().setSize(12.0);
 chartAxisYTitle.getFont().setColor(Color.BLUE);

 doc.save(getArtifactsDir() + "Charts.ChartAxisTitle.docx");
 

Returns: java.lang.String - The text of the axis title.

setOrientation(int value)

public void setOrientation(int value)

Sets the orientation of the axis title text.

Remarks:

The default value is ShapeTextOrientation.HORIZONTAL.

Examples:

Shows how to set orientation and rotation of chart and axis titles.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);
 Shape chartShape = builder.insertChart(ChartType.COLUMN, 400.0, 300.0);
 Chart chart = chartShape.getChart();

 chart.getTitle().setText("Sample Chart");
 chart.getTitle().setOrientation(ShapeTextOrientation.HORIZONTAL);
 chart.getTitle().setRotation(90);

 // Before setting title properties, make sure that this title will be displayed.
 chart.getAxisX().getTitle().setShow(true);
 chart.getAxisX().getTitle().setText("X Axis");
 chart.getAxisX().getTitle().setOrientation(ShapeTextOrientation.HORIZONTAL);
 chart.getAxisX().getTitle().setRotation(-90);

 doc.save(getArtifactsDir() + "Charts.TitleOrientation.docx");
 

Parameters:

ParameterTypeDescription
valueintThe orientation of the axis title text. The value must be one of ShapeTextOrientation constants.

setOverlay(boolean value)

public void setOverlay(boolean value)

Determines whether other chart elements shall be allowed to overlap the title. The default value is false .

Examples:

Shows how to set chart axis title.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);

 Chart chart = shape.getChart();
 ChartSeriesCollection seriesColl = chart.getSeries();
 // Delete default generated series.
 seriesColl.clear();

 seriesColl.add("AW Series 1", new String[] { "AW Category 1", "AW Category 2" }, new double[] { 1.0, 2.0 });

 // Set axis title.
 ChartAxisTitle chartAxisXTitle = chart.getAxisX().getTitle();
 chartAxisXTitle.setText("Categories");
 chartAxisXTitle.setShow(true);
 ChartAxisTitle chartAxisYTitle = chart.getAxisY().getTitle();
 chartAxisYTitle.setText("Values");
 chartAxisYTitle.setShow(true);
 chartAxisYTitle.setOverlay(true);
 chartAxisYTitle.getFont().setSize(12.0);
 chartAxisYTitle.getFont().setColor(Color.BLUE);

 doc.save(getArtifactsDir() + "Charts.ChartAxisTitle.docx");
 

Parameters:

ParameterTypeDescription
valuebooleanThe corresponding boolean value.

setRotation(int value)

public void setRotation(int value)

Sets the rotation of the axis title in degrees.

Remarks:

The range of acceptable values is from -180 to 180 inclusive.

Examples:

Shows how to set orientation and rotation of chart and axis titles.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);
 Shape chartShape = builder.insertChart(ChartType.COLUMN, 400.0, 300.0);
 Chart chart = chartShape.getChart();

 chart.getTitle().setText("Sample Chart");
 chart.getTitle().setOrientation(ShapeTextOrientation.HORIZONTAL);
 chart.getTitle().setRotation(90);

 // Before setting title properties, make sure that this title will be displayed.
 chart.getAxisX().getTitle().setShow(true);
 chart.getAxisX().getTitle().setText("X Axis");
 chart.getAxisX().getTitle().setOrientation(ShapeTextOrientation.HORIZONTAL);
 chart.getAxisX().getTitle().setRotation(-90);

 doc.save(getArtifactsDir() + "Charts.TitleOrientation.docx");
 

Parameters:

ParameterTypeDescription
valueintThe rotation of the axis title in degrees.

setShow(boolean value)

public void setShow(boolean value)

Determines whether the title shall be shown for the axis. The default value is false .

Examples:

Shows how to set chart axis title.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);

 Chart chart = shape.getChart();
 ChartSeriesCollection seriesColl = chart.getSeries();
 // Delete default generated series.
 seriesColl.clear();

 seriesColl.add("AW Series 1", new String[] { "AW Category 1", "AW Category 2" }, new double[] { 1.0, 2.0 });

 // Set axis title.
 ChartAxisTitle chartAxisXTitle = chart.getAxisX().getTitle();
 chartAxisXTitle.setText("Categories");
 chartAxisXTitle.setShow(true);
 ChartAxisTitle chartAxisYTitle = chart.getAxisY().getTitle();
 chartAxisYTitle.setText("Values");
 chartAxisYTitle.setShow(true);
 chartAxisYTitle.setOverlay(true);
 chartAxisYTitle.getFont().setSize(12.0);
 chartAxisYTitle.getFont().setColor(Color.BLUE);

 doc.save(getArtifactsDir() + "Charts.ChartAxisTitle.docx");
 

Parameters:

ParameterTypeDescription
valuebooleanThe corresponding boolean value.

setText(String value)

public void setText(String value)

Sets the text of the axis title. If null or empty value is specified, auto generated title will be shown.

Remarks:

Use getShow() / setShow(boolean) option if you need to show the title.

Examples:

Shows how to set chart axis title.


 Document doc = new Document();
 DocumentBuilder builder = new DocumentBuilder(doc);

 Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);

 Chart chart = shape.getChart();
 ChartSeriesCollection seriesColl = chart.getSeries();
 // Delete default generated series.
 seriesColl.clear();

 seriesColl.add("AW Series 1", new String[] { "AW Category 1", "AW Category 2" }, new double[] { 1.0, 2.0 });

 // Set axis title.
 ChartAxisTitle chartAxisXTitle = chart.getAxisX().getTitle();
 chartAxisXTitle.setText("Categories");
 chartAxisXTitle.setShow(true);
 ChartAxisTitle chartAxisYTitle = chart.getAxisY().getTitle();
 chartAxisYTitle.setText("Values");
 chartAxisYTitle.setShow(true);
 chartAxisYTitle.setOverlay(true);
 chartAxisYTitle.getFont().setSize(12.0);
 chartAxisYTitle.getFont().setColor(Color.BLUE);

 doc.save(getArtifactsDir() + "Charts.ChartAxisTitle.docx");
 

Parameters:

ParameterTypeDescription
valuejava.lang.StringThe text of the axis title.