com.aspose.words
Class AxisTickLabels

java.lang.Object
    extended by com.aspose.words.AxisTickLabels

public class AxisTickLabels 
extends java.lang.Object

Represents properties of axis tick mark labels.

Example:

Shows how to insert a chart and modify the appearance of its axes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertChart(ChartType.COLUMN, 500.0, 300.0);
Chart chart = shape.getChart();

// Clear the chart's demo data series to start with a clean chart.
chart.getSeries().clear();

// Insert a chart series with categories for the X-axis and respective numeric values for the Y-axis.
chart.getSeries().add("Aspose Test Series",
        new String[]{"Word", "PDF", "Excel", "GoogleDocs", "Note"},
        new double[]{640.0, 320.0, 280.0, 120.0, 150.0});

// Chart axes have various options that can change their appearance,
// such as their direction, major/minor unit ticks, and tick marks.
ChartAxis xAxis = chart.getAxisX();
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0d);
xAxis.setMinorUnit(15.0d);
xAxis.getTickLabels().setOffset(50);
xAxis.getTickLabels().setPosition(AxisTickLabelPosition.LOW);
xAxis.getTickLabels().isAutoSpacing(false);
xAxis.setTickMarkSpacing(1);

ChartAxis yAxis = chart.getAxisY();
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0d);
yAxis.setMinorUnit(20.0d);
yAxis.getTickLabels().setPosition(AxisTickLabelPosition.NEXT_TO_AXIS);
yAxis.getTickLabels().setAlignment(ParagraphAlignment.CENTER);
yAxis.getTickLabels().getFont().setColor(Color.RED);
yAxis.getTickLabels().setSpacing(1);

// Column charts do not have a Z-axis.
Assert.assertNull(chart.getAxisZ());

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

Property Getters/Setters Summary
intgetAlignment()
voidsetAlignment(int value)
           Gets or sets text alignment of the axis tick labels. The value of the property is ParagraphAlignment integer constant.
FontgetFont()
           Provides access to font formatting of the tick labels.
booleanisAutoSpacing()
voidisAutoSpacing(boolean value)
           Gets or sets a flag indicating whether to use automatic interval for drawing the tick labels.
intgetOffset()
voidsetOffset(int value)
           Gets or sets the distance of the tick labels from the axis.
intgetOrientation()
voidsetOrientation(int value)
           Gets or sets the orientation of the tick label text. The value of the property is ShapeTextOrientation integer constant.
intgetPosition()
voidsetPosition(int value)
           Gets or sets the position of the tick labels on the axis. The value of the property is AxisTickLabelPosition integer constant.
intgetRotation()
voidsetRotation(int value)
           Gets or sets the rotation of the tick labels in degrees.
intgetSpacing()
voidsetSpacing(int value)
           Gets or sets the interval at which the tick labels are drawn.
 

Property Getters/Setters Detail

getAlignment/setAlignment

public int getAlignment() / public void setAlignment(int value)
Gets or sets text alignment of the axis tick labels. The value of the property is ParagraphAlignment integer constant.

This property has effect only for multi-line labels.

The default value is ParagraphAlignment.CENTER.

.

Example:

Shows how to insert a chart and modify the appearance of its axes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertChart(ChartType.COLUMN, 500.0, 300.0);
Chart chart = shape.getChart();

// Clear the chart's demo data series to start with a clean chart.
chart.getSeries().clear();

// Insert a chart series with categories for the X-axis and respective numeric values for the Y-axis.
chart.getSeries().add("Aspose Test Series",
        new String[]{"Word", "PDF", "Excel", "GoogleDocs", "Note"},
        new double[]{640.0, 320.0, 280.0, 120.0, 150.0});

// Chart axes have various options that can change their appearance,
// such as their direction, major/minor unit ticks, and tick marks.
ChartAxis xAxis = chart.getAxisX();
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0d);
xAxis.setMinorUnit(15.0d);
xAxis.getTickLabels().setOffset(50);
xAxis.getTickLabels().setPosition(AxisTickLabelPosition.LOW);
xAxis.getTickLabels().isAutoSpacing(false);
xAxis.setTickMarkSpacing(1);

ChartAxis yAxis = chart.getAxisY();
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0d);
yAxis.setMinorUnit(20.0d);
yAxis.getTickLabels().setPosition(AxisTickLabelPosition.NEXT_TO_AXIS);
yAxis.getTickLabels().setAlignment(ParagraphAlignment.CENTER);
yAxis.getTickLabels().getFont().setColor(Color.RED);
yAxis.getTickLabels().setSpacing(1);

// Column charts do not have a Z-axis.
Assert.assertNull(chart.getAxisZ());

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

getFont

public Font getFont()
Provides access to font formatting of the tick labels.

Example:

Shows how to insert a chart and modify the appearance of its axes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertChart(ChartType.COLUMN, 500.0, 300.0);
Chart chart = shape.getChart();

// Clear the chart's demo data series to start with a clean chart.
chart.getSeries().clear();

// Insert a chart series with categories for the X-axis and respective numeric values for the Y-axis.
chart.getSeries().add("Aspose Test Series",
        new String[]{"Word", "PDF", "Excel", "GoogleDocs", "Note"},
        new double[]{640.0, 320.0, 280.0, 120.0, 150.0});

// Chart axes have various options that can change their appearance,
// such as their direction, major/minor unit ticks, and tick marks.
ChartAxis xAxis = chart.getAxisX();
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0d);
xAxis.setMinorUnit(15.0d);
xAxis.getTickLabels().setOffset(50);
xAxis.getTickLabels().setPosition(AxisTickLabelPosition.LOW);
xAxis.getTickLabels().isAutoSpacing(false);
xAxis.setTickMarkSpacing(1);

ChartAxis yAxis = chart.getAxisY();
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0d);
yAxis.setMinorUnit(20.0d);
yAxis.getTickLabels().setPosition(AxisTickLabelPosition.NEXT_TO_AXIS);
yAxis.getTickLabels().setAlignment(ParagraphAlignment.CENTER);
yAxis.getTickLabels().getFont().setColor(Color.RED);
yAxis.getTickLabels().setSpacing(1);

// Column charts do not have a Z-axis.
Assert.assertNull(chart.getAxisZ());

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

isAutoSpacing/isAutoSpacing

public boolean isAutoSpacing() / public void isAutoSpacing(boolean value)
Gets or sets a flag indicating whether to use automatic interval for drawing the tick labels.

The default value is true.

The property has effect for text category and series axes. It is not supported by MS Office 2016 new charts.

Example:

Shows how to insert a chart and modify the appearance of its axes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertChart(ChartType.COLUMN, 500.0, 300.0);
Chart chart = shape.getChart();

// Clear the chart's demo data series to start with a clean chart.
chart.getSeries().clear();

// Insert a chart series with categories for the X-axis and respective numeric values for the Y-axis.
chart.getSeries().add("Aspose Test Series",
        new String[]{"Word", "PDF", "Excel", "GoogleDocs", "Note"},
        new double[]{640.0, 320.0, 280.0, 120.0, 150.0});

// Chart axes have various options that can change their appearance,
// such as their direction, major/minor unit ticks, and tick marks.
ChartAxis xAxis = chart.getAxisX();
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0d);
xAxis.setMinorUnit(15.0d);
xAxis.getTickLabels().setOffset(50);
xAxis.getTickLabels().setPosition(AxisTickLabelPosition.LOW);
xAxis.getTickLabels().isAutoSpacing(false);
xAxis.setTickMarkSpacing(1);

ChartAxis yAxis = chart.getAxisY();
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0d);
yAxis.setMinorUnit(20.0d);
yAxis.getTickLabels().setPosition(AxisTickLabelPosition.NEXT_TO_AXIS);
yAxis.getTickLabels().setAlignment(ParagraphAlignment.CENTER);
yAxis.getTickLabels().getFont().setColor(Color.RED);
yAxis.getTickLabels().setSpacing(1);

// Column charts do not have a Z-axis.
Assert.assertNull(chart.getAxisZ());

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

getOffset/setOffset

public int getOffset() / public void setOffset(int value)
Gets or sets the distance of the tick labels from the axis.

The property represents a percentage of the default label offset.

Valid range is from 0 to 1000 percent inclusive. The default value is 100%.

The property has effect only for category axes. It is not supported by MS Office 2016 new charts.

Example:

Shows how to insert a chart and modify the appearance of its axes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertChart(ChartType.COLUMN, 500.0, 300.0);
Chart chart = shape.getChart();

// Clear the chart's demo data series to start with a clean chart.
chart.getSeries().clear();

// Insert a chart series with categories for the X-axis and respective numeric values for the Y-axis.
chart.getSeries().add("Aspose Test Series",
        new String[]{"Word", "PDF", "Excel", "GoogleDocs", "Note"},
        new double[]{640.0, 320.0, 280.0, 120.0, 150.0});

// Chart axes have various options that can change their appearance,
// such as their direction, major/minor unit ticks, and tick marks.
ChartAxis xAxis = chart.getAxisX();
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0d);
xAxis.setMinorUnit(15.0d);
xAxis.getTickLabels().setOffset(50);
xAxis.getTickLabels().setPosition(AxisTickLabelPosition.LOW);
xAxis.getTickLabels().isAutoSpacing(false);
xAxis.setTickMarkSpacing(1);

ChartAxis yAxis = chart.getAxisY();
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0d);
yAxis.setMinorUnit(20.0d);
yAxis.getTickLabels().setPosition(AxisTickLabelPosition.NEXT_TO_AXIS);
yAxis.getTickLabels().setAlignment(ParagraphAlignment.CENTER);
yAxis.getTickLabels().getFont().setColor(Color.RED);
yAxis.getTickLabels().setSpacing(1);

// Column charts do not have a Z-axis.
Assert.assertNull(chart.getAxisZ());

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

getOrientation/setOrientation

public int getOrientation() / public void setOrientation(int value)
Gets or sets the orientation of the tick label text. The value of the property is ShapeTextOrientation integer constant.

The default value is ShapeTextOrientation.HORIZONTAL.

Note that some ShapeTextOrientation values do not affect the orientation of tick label text in value axes.

Example:

Shows how to change orientation and rotation for axis tick labels.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a column chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
AxisTickLabels xTickLabels = shape.getChart().getAxisX().getTickLabels();
AxisTickLabels yTickLabels = shape.getChart().getAxisY().getTickLabels();

// Set axis tick label orientation and rotation.
xTickLabels.setOrientation(ShapeTextOrientation.VERTICAL_FAR_EAST);
xTickLabels.setRotation(-30);
yTickLabels.setOrientation(ShapeTextOrientation.HORIZONTAL);
yTickLabels.setRotation(45);

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

getPosition/setPosition

public int getPosition() / public void setPosition(int value)
Gets or sets the position of the tick labels on the axis. The value of the property is AxisTickLabelPosition integer constant. The property is not supported by MS Office 2016 new charts.

Example:

Shows how to insert a chart and modify the appearance of its axes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertChart(ChartType.COLUMN, 500.0, 300.0);
Chart chart = shape.getChart();

// Clear the chart's demo data series to start with a clean chart.
chart.getSeries().clear();

// Insert a chart series with categories for the X-axis and respective numeric values for the Y-axis.
chart.getSeries().add("Aspose Test Series",
        new String[]{"Word", "PDF", "Excel", "GoogleDocs", "Note"},
        new double[]{640.0, 320.0, 280.0, 120.0, 150.0});

// Chart axes have various options that can change their appearance,
// such as their direction, major/minor unit ticks, and tick marks.
ChartAxis xAxis = chart.getAxisX();
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0d);
xAxis.setMinorUnit(15.0d);
xAxis.getTickLabels().setOffset(50);
xAxis.getTickLabels().setPosition(AxisTickLabelPosition.LOW);
xAxis.getTickLabels().isAutoSpacing(false);
xAxis.setTickMarkSpacing(1);

ChartAxis yAxis = chart.getAxisY();
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0d);
yAxis.setMinorUnit(20.0d);
yAxis.getTickLabels().setPosition(AxisTickLabelPosition.NEXT_TO_AXIS);
yAxis.getTickLabels().setAlignment(ParagraphAlignment.CENTER);
yAxis.getTickLabels().getFont().setColor(Color.RED);
yAxis.getTickLabels().setSpacing(1);

// Column charts do not have a Z-axis.
Assert.assertNull(chart.getAxisZ());

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

getRotation/setRotation

public int getRotation() / public void setRotation(int value)
Gets or sets the rotation of the tick labels in degrees. The range of acceptable values is from -180 to 180 inclusive. The default value is 0.

Example:

Shows how to change orientation and rotation for axis tick labels.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a column chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
AxisTickLabels xTickLabels = shape.getChart().getAxisX().getTickLabels();
AxisTickLabels yTickLabels = shape.getChart().getAxisY().getTickLabels();

// Set axis tick label orientation and rotation.
xTickLabels.setOrientation(ShapeTextOrientation.VERTICAL_FAR_EAST);
xTickLabels.setRotation(-30);
yTickLabels.setOrientation(ShapeTextOrientation.HORIZONTAL);
yTickLabels.setRotation(45);

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

getSpacing/setSpacing

public int getSpacing() / public void setSpacing(int value)
Gets or sets the interval at which the tick labels are drawn.

The property has effect for text category and series axes. It is not supported by MS Office 2016 new charts. Valid range of a value is greater than or equal to 1.

Setting this property sets the IsAutoSpacing property to false.

Example:

Shows how to insert a chart and modify the appearance of its axes.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.insertChart(ChartType.COLUMN, 500.0, 300.0);
Chart chart = shape.getChart();

// Clear the chart's demo data series to start with a clean chart.
chart.getSeries().clear();

// Insert a chart series with categories for the X-axis and respective numeric values for the Y-axis.
chart.getSeries().add("Aspose Test Series",
        new String[]{"Word", "PDF", "Excel", "GoogleDocs", "Note"},
        new double[]{640.0, 320.0, 280.0, 120.0, 150.0});

// Chart axes have various options that can change their appearance,
// such as their direction, major/minor unit ticks, and tick marks.
ChartAxis xAxis = chart.getAxisX();
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0d);
xAxis.setMinorUnit(15.0d);
xAxis.getTickLabels().setOffset(50);
xAxis.getTickLabels().setPosition(AxisTickLabelPosition.LOW);
xAxis.getTickLabels().isAutoSpacing(false);
xAxis.setTickMarkSpacing(1);

ChartAxis yAxis = chart.getAxisY();
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0d);
yAxis.setMinorUnit(20.0d);
yAxis.getTickLabels().setPosition(AxisTickLabelPosition.NEXT_TO_AXIS);
yAxis.getTickLabels().setAlignment(ParagraphAlignment.CENTER);
yAxis.getTickLabels().getFont().setColor(Color.RED);
yAxis.getTickLabels().setSpacing(1);

// Column charts do not have a Z-axis.
Assert.assertNull(chart.getAxisZ());

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

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.