AxisTickLabels
Inheritance: java.lang.Object
public class AxisTickLabels
Represents properties of axis tick mark labels.
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Methods
Method | Description |
---|---|
fetchSpecialDefaultRunPropertyValue(int key) | |
generateItemText() | |
getAlignment() | Gets text alignment of the axis tick labels. |
getFont() | Provides access to font formatting of the tick labels. |
getOffset() | Gets the distance of the tick labels from the axis. |
getOrientation() | Gets the orientation of the tick label text. |
getPosition() | Gets the position of the tick labels on the axis. |
getRelativePropertyValue(int key, Object value) | |
getRotation() | Gets the rotation of the tick labels in degrees. |
getSpacing() | Gets the interval at which the tick labels are drawn. |
isAutoSpacing() | Gets a flag indicating whether to use automatic interval for drawing the tick labels. |
isAutoSpacing(boolean value) | Sets a flag indicating whether to use automatic interval for drawing the tick labels. |
setAlignment(int value) | Sets text alignment of the axis tick labels. |
setOffset(int value) | Sets the distance of the tick labels from the axis. |
setOrientation(int value) | Sets the orientation of the tick label text. |
setPosition(int value) | Sets the position of the tick labels on the axis. |
setRotation(int value) | Sets the rotation of the tick labels in degrees. |
setSpacing(int value) | Sets the interval at which the tick labels are drawn. |
fetchSpecialDefaultRunPropertyValue(int key)
public Object fetchSpecialDefaultRunPropertyValue(int key)
Parameters:
Parameter | Type | Description |
---|---|---|
key | int |
Returns: java.lang.Object
generateItemText()
public String generateItemText()
Returns: java.lang.String
getAlignment()
public int getAlignment()
Gets text alignment of the axis tick labels.
Remarks:
This property has effect only for multi-line labels.
The default value is ParagraphAlignment.CENTER.
.
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Returns: int - Text alignment of the axis tick labels. The returned value is one of ParagraphAlignment constants.
getFont()
public Font getFont()
Provides access to font formatting of the tick labels.
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Returns: Font - The corresponding Font value.
getOffset()
public int getOffset()
Gets the distance of the tick labels from the axis.
Remarks:
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.
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Returns: int - The distance of the tick labels from the axis.
getOrientation()
public int getOrientation()
Gets the orientation of the tick label text.
Remarks:
The default value is ShapeTextOrientation.HORIZONTAL.
Note that some ShapeTextOrientation values do not affect the orientation of tick label text in value axes.
Examples:
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");
Returns: int - The orientation of the tick label text. The returned value is one of ShapeTextOrientation constants.
getPosition()
public int getPosition()
Gets the position of the tick labels on the axis.
Remarks:
The property is not supported by MS Office 2016 new charts.
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Returns: int - The position of the tick labels on the axis. The returned value is one of AxisTickLabelPosition constants.
getRelativePropertyValue(int key, Object value)
public Object getRelativePropertyValue(int key, Object value)
Parameters:
Parameter | Type | Description |
---|---|---|
key | int | |
value | java.lang.Object |
Returns: java.lang.Object
getRotation()
public int getRotation()
Gets the rotation of the tick labels in degrees.
Remarks:
The range of acceptable values is from -180 to 180 inclusive. The default value is 0.
Examples:
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");
Returns: int - The rotation of the tick labels in degrees.
getSpacing()
public int getSpacing()
Gets the interval at which the tick labels are drawn.
Remarks:
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() / isAutoSpacing(boolean) property to false .
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Returns: int - The interval at which the tick labels are drawn.
isAutoSpacing()
public boolean isAutoSpacing()
Gets a flag indicating whether to use automatic interval for drawing the tick labels.
Remarks:
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.
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Returns: boolean - A flag indicating whether to use automatic interval for drawing the tick labels.
isAutoSpacing(boolean value)
public void isAutoSpacing(boolean value)
Sets a flag indicating whether to use automatic interval for drawing the tick labels.
Remarks:
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.
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | A flag indicating whether to use automatic interval for drawing the tick labels. |
setAlignment(int value)
public void setAlignment(int value)
Sets text alignment of the axis tick labels.
Remarks:
This property has effect only for multi-line labels.
The default value is ParagraphAlignment.CENTER.
.
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | Text alignment of the axis tick labels. The value must be one of ParagraphAlignment constants. |
setOffset(int value)
public void setOffset(int value)
Sets the distance of the tick labels from the axis.
Remarks:
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.
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The distance of the tick labels from the axis. |
setOrientation(int value)
public void setOrientation(int value)
Sets the orientation of the tick label text.
Remarks:
The default value is ShapeTextOrientation.HORIZONTAL.
Note that some ShapeTextOrientation values do not affect the orientation of tick label text in value axes.
Examples:
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");
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The orientation of the tick label text. The value must be one of ShapeTextOrientation constants. |
setPosition(int value)
public void setPosition(int value)
Sets the position of the tick labels on the axis.
Remarks:
The property is not supported by MS Office 2016 new charts.
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The position of the tick labels on the axis. The value must be one of AxisTickLabelPosition constants. |
setRotation(int value)
public void setRotation(int value)
Sets the rotation of the tick labels in degrees.
Remarks:
The range of acceptable values is from -180 to 180 inclusive. The default value is 0.
Examples:
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");
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The rotation of the tick labels in degrees. |
setSpacing(int value)
public void setSpacing(int value)
Sets the interval at which the tick labels are drawn.
Remarks:
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() / isAutoSpacing(boolean) property to false .
Examples:
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);
Assert.assertEquals(doc, xAxis.getDocument());
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");
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The interval at which the tick labels are drawn. |