java.lang.Object
com.aspose.words.ChartAxis
public class ChartAxis
Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);
| Property Getters/Setters Summary | ||
|---|---|---|
boolean | getAxisBetweenCategories() | |
void | setAxisBetweenCategories(boolean value) | |
| Gets or sets a flag indicating whether the value axis crosses the category axis between categories. | ||
int | getBaseTimeUnit() | |
void | setBaseTimeUnit(int value) | |
| Returns or sets the smallest time unit that is represented on the time category axis. The value of the property is AxisTimeUnit integer constant. | ||
int | getCategoryType() | |
void | setCategoryType(int value) | |
| Gets or sets type of the category axis. The value of the property is AxisCategoryType integer constant. | ||
int | getCrosses() | |
void | setCrosses(int value) | |
| Specifies how this axis crosses the perpendicular axis. The value of the property is AxisCrosses integer constant. | ||
double | getCrossesAt() | |
void | setCrossesAt(double value) | |
| Specifies where on the perpendicular axis the axis crosses. | ||
AxisDisplayUnit | getDisplayUnit() | |
| Specifies the scaling value of the display units for the value axis. | ||
DocumentBase | getDocument() | |
| Returns the Document the title holder belongs. | ||
boolean | getHidden() | |
void | setHidden(boolean value) | |
| Gets or sets a flag indicating whether this axis is hidden or not. | ||
int | getMajorTickMark() | |
void | setMajorTickMark(int value) | |
| Returns or sets the major tick marks. The value of the property is AxisTickMark integer constant. | ||
double | getMajorUnit() | |
void | setMajorUnit(double value) | |
| Returns or sets the distance between major tick marks. | ||
boolean | getMajorUnitIsAuto() | |
void | setMajorUnitIsAuto(boolean value) | |
| Gets or sets a flag indicating whether default distance between major tick marks shall be used. | ||
int | getMajorUnitScale() | |
void | setMajorUnitScale(int value) | |
| Returns or sets the scale value for major tick marks on the time category axis. The value of the property is AxisTimeUnit integer constant. | ||
int | getMinorTickMark() | |
void | setMinorTickMark(int value) | |
| Returns or sets the minor tick marks for the axis. The value of the property is AxisTickMark integer constant. | ||
double | getMinorUnit() | |
void | setMinorUnit(double value) | |
| Returns or sets the distance between minor tick marks. | ||
boolean | getMinorUnitIsAuto() | |
void | setMinorUnitIsAuto(boolean value) | |
| Gets or sets a flag indicating whether default distance between minor tick marks shall be used. | ||
int | getMinorUnitScale() | |
void | setMinorUnitScale(int value) | |
| Returns or sets the scale value for minor tick marks on the time category axis. The value of the property is AxisTimeUnit integer constant. | ||
ChartNumberFormat | getNumberFormat() | |
|
Returns a |
||
boolean | getReverseOrder() | |
void | setReverseOrder(boolean value) | |
| Returns or sets a flag indicating whether values of axis should be displayed in reverse order, i.e. from max to min. | ||
AxisScaling | getScaling() | |
| Provides access to the scaling options of the axis. | ||
int | getTickLabelAlignment() | |
void | setTickLabelAlignment(int value) | |
| Gets or sets text alignment of axis tick labels. The value of the property is ParagraphAlignment integer constant. | ||
int | getTickLabelOffset() | |
void | setTickLabelOffset(int value) | |
| Gets or sets the distance of labels from the axis. | ||
int | getTickLabelPosition() | |
void | setTickLabelPosition(int value) | |
| Returns or sets the position of the tick labels on the axis. The value of the property is AxisTickLabelPosition integer constant. | ||
int | getTickLabelSpacing() | |
void | setTickLabelSpacing(int value) | |
| Gets or sets the interval, at which tick labels are drawn. | ||
boolean | getTickLabelSpacingIsAuto() | |
void | setTickLabelSpacingIsAuto(boolean value) | |
| Gets or sets a flag indicating whether automatic interval of drawing tick labels shall be used. | ||
int | getTickMarkSpacing() | |
void | setTickMarkSpacing(int value) | |
| Gets or sets the interval, at which tick marks are drawn. | ||
int | getType() | |
| Returns type of the axis. The value of the property is ChartAxisType integer constant. | ||
| Property Getters/Setters Detail |
|---|
getAxisBetweenCategories/setAxisBetweenCategories | |
public boolean getAxisBetweenCategories() / public void setAxisBetweenCategories(boolean value) | |
Example:
Shows how to get a graph axis to cross at a custom location.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a column chart, which is populated by default values Shape shape = builder.insertChart(ChartType.COLUMN, 450.0, 250.0); Chart chart = shape.getChart(); // Get the Y-axis to cross at a value of 3.0, making 3.0 the new Y-zero of our column chart // This effectively means that all the columns with Y-values about 3.0 will be above the Y-centre and point up, // while ones below 3.0 will point down ChartAxis axis = chart.getAxisX(); axis.setAxisBetweenCategories(true); axis.setCrosses(AxisCrosses.CUSTOM); axis.setCrossesAt(3.0); doc.save(getArtifactsDir() + "Charts.AxisCross.docx");
getBaseTimeUnit/setBaseTimeUnit | |
public int getBaseTimeUnit() / public void setBaseTimeUnit(int value) | |
Example:
Shows how to insert chart with date/time values
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.LINE, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
Calendar cal = Calendar.getInstance();
// Fill data.
chart.getSeries().add("Aspose Test Series",
new Date[]
{
DocumentHelper.createDate(2017, 11, 6), DocumentHelper.createDate(2017, 11, 9), DocumentHelper.createDate(2017, 11, 15),
DocumentHelper.createDate(2017, 11, 21), DocumentHelper.createDate(2017, 11, 25), DocumentHelper.createDate(2017, 11, 29)
},
new double[]{1.2, 0.3, 2.1, 2.9, 4.2, 5.3});
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// Set X axis bounds.
xAxis.getScaling().setMinimum(new AxisBound(DocumentHelper.createDate(2017, 11, 5)));
xAxis.getScaling().setMaximum(new AxisBound(DocumentHelper.createDate(2017, 12, 3)));
// Set major units to a week and minor units to a day.
xAxis.setBaseTimeUnit(AxisTimeUnit.DAYS);
xAxis.setMajorUnit(7.0);
xAxis.setMinorUnit(1.0);
xAxis.setMajorTickMark(AxisTickMark.CROSS);
xAxis.setMinorTickMark(AxisTickMark.OUTSIDE);
// Define Y axis properties.
yAxis.setTickLabelPosition(AxisTickLabelPosition.HIGH);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(50.0);
yAxis.getDisplayUnit().setUnit(AxisBuiltInUnit.HUNDREDS);
yAxis.getScaling().setMinimum(new AxisBound(100.0));
yAxis.getScaling().setMaximum(new AxisBound(700.0));
doc.save(getArtifactsDir() + "Charts.ChartAxisProperties.docx");getCategoryType/setCategoryType | |
public int getCategoryType() / public void setCategoryType(int value) | |
Example:
Shows how to insert chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getCrosses/setCrosses | |
public int getCrosses() / public void setCrosses(int value) | |
Default value is
The property is not supported by MS Office 2016 new charts.
Example:
Shows how to insert chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getCrossesAt/setCrossesAt | |
public double getCrossesAt() / public void setCrossesAt(double value) | |
The property has effect only if
The units are determined by the type of axis. When the axis is a value axis, the value of the property is a decimal number on the value axis. When the axis is a time category axis, the value is defined as an integer number of days relative to the base date (30/12/1899). For a text category axis, the value is an integer category number, starting with 1 as the first category.
Example:
Shows how to get a graph axis to cross at a custom location.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a column chart, which is populated by default values Shape shape = builder.insertChart(ChartType.COLUMN, 450.0, 250.0); Chart chart = shape.getChart(); // Get the Y-axis to cross at a value of 3.0, making 3.0 the new Y-zero of our column chart // This effectively means that all the columns with Y-values about 3.0 will be above the Y-centre and point up, // while ones below 3.0 will point down ChartAxis axis = chart.getAxisX(); axis.setAxisBetweenCategories(true); axis.setCrosses(AxisCrosses.CUSTOM); axis.setCrossesAt(3.0); doc.save(getArtifactsDir() + "Charts.AxisCross.docx");
getDisplayUnit | |
public AxisDisplayUnit getDisplayUnit() | |
Example:
Shows how to manipulate the tick marks and displayed values of a chart axis.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a scatter chart, which is populated by default values Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0); Chart chart = shape.getChart(); // Set they Y axis to show major ticks every at every 10 units and minor ticks at every 1 units ChartAxis axis = chart.getAxisY(); axis.setMajorTickMark(AxisTickMark.OUTSIDE); axis.setMinorTickMark(AxisTickMark.OUTSIDE); axis.setMajorUnit(10.0); axis.setMinorUnit(1.0); // Stretch out the bounds of the axis out to show 3 major ticks and 27 minor ticks axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(20.0)); // Do the same for the X-axis axis = chart.getAxisX(); axis.setMajorTickMark(AxisTickMark.INSIDE); axis.setMinorTickMark(AxisTickMark.INSIDE); axis.setMajorUnit(10.0); axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(30.0)); // We can also use this attribute to set minor tick spacing axis.setTickLabelSpacing(2); // We can define text alignment when axis tick labels are multi-line // MS Word aligns them to the center by default axis.setTickLabelAlignment(ParagraphAlignment.RIGHT); // Get the axis to display values, but in millions axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS); // Besides the built-in axis units we can choose from, // we can also set the axis to display values in some custom denomination, using the following attribute // The statement below is equivalent to the one above axis.getDisplayUnit().setCustomUnit(1000000.0); doc.save(getArtifactsDir() + "Charts.ChartAxisDisplayUnit.docx");
getDocument | |
public DocumentBase getDocument() | |
getHidden/setHidden | |
public boolean getHidden() / public void setHidden(boolean value) | |
Example:
Shows how to hide chart axises.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.LINE, 432.0, 252.0);
Chart chart = shape.getChart();
chart.getAxisX().setHidden(true);
chart.getAxisY().setHidden(true);
// Clear demo data.
chart.getSeries().clear();
chart.getSeries().add("AW Series 1",
new String[]{"Item 1", "Item 2", "Item 3", "Item 4", "Item 5"},
new double[]{1.2, 0.3, 2.1, 2.9, 4.2});
ByteArrayOutputStream dstStream = new ByteArrayOutputStream();
doc.save(dstStream, SaveFormat.DOCX);
shape = (Shape) doc.getChild(NodeType.SHAPE, 0, true);
chart = shape.getChart();
Assert.assertEquals(chart.getAxisX().getHidden(), true);
Assert.assertEquals(chart.getAxisY().getHidden(), true);getMajorTickMark/setMajorTickMark | |
public int getMajorTickMark() / public void setMajorTickMark(int value) | |
Example:
Shows how to insert chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getMajorUnit/setMajorUnit | |
public double getMajorUnit() / public void setMajorUnit(double value) | |
Valid range of a value is greater than zero. The property has effect for time category and value axes.
Setting this property sets the
Example:
Shows how to insert chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getMajorUnitIsAuto/setMajorUnitIsAuto | |
public boolean getMajorUnitIsAuto() / public void setMajorUnitIsAuto(boolean value) | |
Example:
Shows how to manipulate the tick marks and displayed values of a chart axis.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a scatter chart, which is populated by default values Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0); Chart chart = shape.getChart(); // Set they Y axis to show major ticks every at every 10 units and minor ticks at every 1 units ChartAxis axis = chart.getAxisY(); axis.setMajorTickMark(AxisTickMark.OUTSIDE); axis.setMinorTickMark(AxisTickMark.OUTSIDE); axis.setMajorUnit(10.0); axis.setMinorUnit(1.0); // Stretch out the bounds of the axis out to show 3 major ticks and 27 minor ticks axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(20.0)); // Do the same for the X-axis axis = chart.getAxisX(); axis.setMajorTickMark(AxisTickMark.INSIDE); axis.setMinorTickMark(AxisTickMark.INSIDE); axis.setMajorUnit(10.0); axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(30.0)); // We can also use this attribute to set minor tick spacing axis.setTickLabelSpacing(2); // We can define text alignment when axis tick labels are multi-line // MS Word aligns them to the center by default axis.setTickLabelAlignment(ParagraphAlignment.RIGHT); // Get the axis to display values, but in millions axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS); // Besides the built-in axis units we can choose from, // we can also set the axis to display values in some custom denomination, using the following attribute // The statement below is equivalent to the one above axis.getDisplayUnit().setCustomUnit(1000000.0); doc.save(getArtifactsDir() + "Charts.ChartAxisDisplayUnit.docx");
getMajorUnitScale/setMajorUnitScale | |
public int getMajorUnitScale() / public void setMajorUnitScale(int value) | |
Example:
Shows how to manipulate the tick marks and displayed values of a chart axis.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a scatter chart, which is populated by default values Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0); Chart chart = shape.getChart(); // Set they Y axis to show major ticks every at every 10 units and minor ticks at every 1 units ChartAxis axis = chart.getAxisY(); axis.setMajorTickMark(AxisTickMark.OUTSIDE); axis.setMinorTickMark(AxisTickMark.OUTSIDE); axis.setMajorUnit(10.0); axis.setMinorUnit(1.0); // Stretch out the bounds of the axis out to show 3 major ticks and 27 minor ticks axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(20.0)); // Do the same for the X-axis axis = chart.getAxisX(); axis.setMajorTickMark(AxisTickMark.INSIDE); axis.setMinorTickMark(AxisTickMark.INSIDE); axis.setMajorUnit(10.0); axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(30.0)); // We can also use this attribute to set minor tick spacing axis.setTickLabelSpacing(2); // We can define text alignment when axis tick labels are multi-line // MS Word aligns them to the center by default axis.setTickLabelAlignment(ParagraphAlignment.RIGHT); // Get the axis to display values, but in millions axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS); // Besides the built-in axis units we can choose from, // we can also set the axis to display values in some custom denomination, using the following attribute // The statement below is equivalent to the one above axis.getDisplayUnit().setCustomUnit(1000000.0); doc.save(getArtifactsDir() + "Charts.ChartAxisDisplayUnit.docx");
getMinorTickMark/setMinorTickMark | |
public int getMinorTickMark() / public void setMinorTickMark(int value) | |
Example:
Shows how to insert chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getMinorUnit/setMinorUnit | |
public double getMinorUnit() / public void setMinorUnit(double value) | |
Valid range of a value is greater than zero. The property has effect for time category and value axes.
Setting this property sets the
Example:
Shows how to insert chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getMinorUnitIsAuto/setMinorUnitIsAuto | |
public boolean getMinorUnitIsAuto() / public void setMinorUnitIsAuto(boolean value) | |
Example:
Shows how to manipulate the tick marks and displayed values of a chart axis.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a scatter chart, which is populated by default values Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0); Chart chart = shape.getChart(); // Set they Y axis to show major ticks every at every 10 units and minor ticks at every 1 units ChartAxis axis = chart.getAxisY(); axis.setMajorTickMark(AxisTickMark.OUTSIDE); axis.setMinorTickMark(AxisTickMark.OUTSIDE); axis.setMajorUnit(10.0); axis.setMinorUnit(1.0); // Stretch out the bounds of the axis out to show 3 major ticks and 27 minor ticks axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(20.0)); // Do the same for the X-axis axis = chart.getAxisX(); axis.setMajorTickMark(AxisTickMark.INSIDE); axis.setMinorTickMark(AxisTickMark.INSIDE); axis.setMajorUnit(10.0); axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(30.0)); // We can also use this attribute to set minor tick spacing axis.setTickLabelSpacing(2); // We can define text alignment when axis tick labels are multi-line // MS Word aligns them to the center by default axis.setTickLabelAlignment(ParagraphAlignment.RIGHT); // Get the axis to display values, but in millions axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS); // Besides the built-in axis units we can choose from, // we can also set the axis to display values in some custom denomination, using the following attribute // The statement below is equivalent to the one above axis.getDisplayUnit().setCustomUnit(1000000.0); doc.save(getArtifactsDir() + "Charts.ChartAxisDisplayUnit.docx");
getMinorUnitScale/setMinorUnitScale | |
public int getMinorUnitScale() / public void setMinorUnitScale(int value) | |
Example:
Shows how to manipulate the tick marks and displayed values of a chart axis.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a scatter chart, which is populated by default values Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0); Chart chart = shape.getChart(); // Set they Y axis to show major ticks every at every 10 units and minor ticks at every 1 units ChartAxis axis = chart.getAxisY(); axis.setMajorTickMark(AxisTickMark.OUTSIDE); axis.setMinorTickMark(AxisTickMark.OUTSIDE); axis.setMajorUnit(10.0); axis.setMinorUnit(1.0); // Stretch out the bounds of the axis out to show 3 major ticks and 27 minor ticks axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(20.0)); // Do the same for the X-axis axis = chart.getAxisX(); axis.setMajorTickMark(AxisTickMark.INSIDE); axis.setMinorTickMark(AxisTickMark.INSIDE); axis.setMajorUnit(10.0); axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(30.0)); // We can also use this attribute to set minor tick spacing axis.setTickLabelSpacing(2); // We can define text alignment when axis tick labels are multi-line // MS Word aligns them to the center by default axis.setTickLabelAlignment(ParagraphAlignment.RIGHT); // Get the axis to display values, but in millions axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS); // Besides the built-in axis units we can choose from, // we can also set the axis to display values in some custom denomination, using the following attribute // The statement below is equivalent to the one above axis.getDisplayUnit().setCustomUnit(1000000.0); doc.save(getArtifactsDir() + "Charts.ChartAxisDisplayUnit.docx");
getNumberFormat | |
public ChartNumberFormat getNumberFormat() | |
Example:
Shows how to set formatting for chart values.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
chart.getSeries().add("Aspose Test Series",
new String[]{"Word", "PDF", "Excel", "GoogleDocs", "Note"},
new double[]{1900000.0, 850000.0, 2100000.0, 600000.0, 1500000.0});
// Set number format.
chart.getAxisY().getNumberFormat().setFormatCode("#,##0");
// Set this to override the above value and draw the number format from the source cell
Assert.assertFalse(chart.getAxisY().getNumberFormat().isLinkedToSource());getReverseOrder/setReverseOrder | |
public boolean getReverseOrder() / public void setReverseOrder(boolean value) | |
Example:
Shows how to insert chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getScaling | |
public AxisScaling getScaling() | |
Example:
Shows how to insert chart with date/time values
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.LINE, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
Calendar cal = Calendar.getInstance();
// Fill data.
chart.getSeries().add("Aspose Test Series",
new Date[]
{
DocumentHelper.createDate(2017, 11, 6), DocumentHelper.createDate(2017, 11, 9), DocumentHelper.createDate(2017, 11, 15),
DocumentHelper.createDate(2017, 11, 21), DocumentHelper.createDate(2017, 11, 25), DocumentHelper.createDate(2017, 11, 29)
},
new double[]{1.2, 0.3, 2.1, 2.9, 4.2, 5.3});
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// Set X axis bounds.
xAxis.getScaling().setMinimum(new AxisBound(DocumentHelper.createDate(2017, 11, 5)));
xAxis.getScaling().setMaximum(new AxisBound(DocumentHelper.createDate(2017, 12, 3)));
// Set major units to a week and minor units to a day.
xAxis.setBaseTimeUnit(AxisTimeUnit.DAYS);
xAxis.setMajorUnit(7.0);
xAxis.setMinorUnit(1.0);
xAxis.setMajorTickMark(AxisTickMark.CROSS);
xAxis.setMinorTickMark(AxisTickMark.OUTSIDE);
// Define Y axis properties.
yAxis.setTickLabelPosition(AxisTickLabelPosition.HIGH);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(50.0);
yAxis.getDisplayUnit().setUnit(AxisBuiltInUnit.HUNDREDS);
yAxis.getScaling().setMinimum(new AxisBound(100.0));
yAxis.getScaling().setMaximum(new AxisBound(700.0));
doc.save(getArtifactsDir() + "Charts.ChartAxisProperties.docx");getTickLabelAlignment/setTickLabelAlignment | |
public int getTickLabelAlignment() / public void setTickLabelAlignment(int value) | |
This property has effect only for multi-line labels.
Default value is
Example:
Shows how to manipulate the tick marks and displayed values of a chart axis.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a scatter chart, which is populated by default values Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0); Chart chart = shape.getChart(); // Set they Y axis to show major ticks every at every 10 units and minor ticks at every 1 units ChartAxis axis = chart.getAxisY(); axis.setMajorTickMark(AxisTickMark.OUTSIDE); axis.setMinorTickMark(AxisTickMark.OUTSIDE); axis.setMajorUnit(10.0); axis.setMinorUnit(1.0); // Stretch out the bounds of the axis out to show 3 major ticks and 27 minor ticks axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(20.0)); // Do the same for the X-axis axis = chart.getAxisX(); axis.setMajorTickMark(AxisTickMark.INSIDE); axis.setMinorTickMark(AxisTickMark.INSIDE); axis.setMajorUnit(10.0); axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(30.0)); // We can also use this attribute to set minor tick spacing axis.setTickLabelSpacing(2); // We can define text alignment when axis tick labels are multi-line // MS Word aligns them to the center by default axis.setTickLabelAlignment(ParagraphAlignment.RIGHT); // Get the axis to display values, but in millions axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS); // Besides the built-in axis units we can choose from, // we can also set the axis to display values in some custom denomination, using the following attribute // The statement below is equivalent to the one above axis.getDisplayUnit().setCustomUnit(1000000.0); doc.save(getArtifactsDir() + "Charts.ChartAxisDisplayUnit.docx");
getTickLabelOffset/setTickLabelOffset | |
public int getTickLabelOffset() / public void setTickLabelOffset(int value) | |
The property represents a percentage of the default label offset.
Valid range is from 0 to 1000 percent inclusive. 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 chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getTickLabelPosition/setTickLabelPosition | |
public int getTickLabelPosition() / public void setTickLabelPosition(int value) | |
Example:
Shows how to insert chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getTickLabelSpacing/setTickLabelSpacing | |
public int getTickLabelSpacing() / public void setTickLabelSpacing(int value) | |
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
Example:
Shows how to manipulate the tick marks and displayed values of a chart axis.Document doc = new Document(); DocumentBuilder builder = new DocumentBuilder(doc); // Insert a scatter chart, which is populated by default values Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0); Chart chart = shape.getChart(); // Set they Y axis to show major ticks every at every 10 units and minor ticks at every 1 units ChartAxis axis = chart.getAxisY(); axis.setMajorTickMark(AxisTickMark.OUTSIDE); axis.setMinorTickMark(AxisTickMark.OUTSIDE); axis.setMajorUnit(10.0); axis.setMinorUnit(1.0); // Stretch out the bounds of the axis out to show 3 major ticks and 27 minor ticks axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(20.0)); // Do the same for the X-axis axis = chart.getAxisX(); axis.setMajorTickMark(AxisTickMark.INSIDE); axis.setMinorTickMark(AxisTickMark.INSIDE); axis.setMajorUnit(10.0); axis.getScaling().setMinimum(new AxisBound(-10)); axis.getScaling().setMaximum(new AxisBound(30.0)); // We can also use this attribute to set minor tick spacing axis.setTickLabelSpacing(2); // We can define text alignment when axis tick labels are multi-line // MS Word aligns them to the center by default axis.setTickLabelAlignment(ParagraphAlignment.RIGHT); // Get the axis to display values, but in millions axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS); // Besides the built-in axis units we can choose from, // we can also set the axis to display values in some custom denomination, using the following attribute // The statement below is equivalent to the one above axis.getDisplayUnit().setCustomUnit(1000000.0); doc.save(getArtifactsDir() + "Charts.ChartAxisDisplayUnit.docx");
getTickLabelSpacingIsAuto/setTickLabelSpacingIsAuto | |
public boolean getTickLabelSpacingIsAuto() / public void setTickLabelSpacingIsAuto(boolean value) | |
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 chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getTickMarkSpacing/setTickMarkSpacing | |
public int getTickMarkSpacing() / public void setTickMarkSpacing(int value) | |
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.
Example:
Shows how to insert chart using the axis options for detailed configuration.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart.
Shape shape = builder.insertChart(ChartType.COLUMN, 432.0, 252.0);
Chart chart = shape.getChart();
// Clear demo data.
chart.getSeries().clear();
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});
// Get chart axes
ChartAxis xAxis = chart.getAxisX();
ChartAxis yAxis = chart.getAxisY();
// For 2D charts like the one we made, the Z axis is null
Assert.assertNull(chart.getAxisZ());
// Set X-axis options
xAxis.setCategoryType(AxisCategoryType.CATEGORY);
xAxis.setCrosses(AxisCrosses.MINIMUM);
xAxis.setReverseOrder(false);
xAxis.setMajorTickMark(AxisTickMark.INSIDE);
xAxis.setMinorTickMark(AxisTickMark.CROSS);
xAxis.setMajorUnit(10.0);
xAxis.setMinorUnit(15.0);
xAxis.setTickLabelOffset(50);
xAxis.setTickLabelPosition(AxisTickLabelPosition.LOW);
xAxis.setTickLabelSpacingIsAuto(false);
xAxis.setTickMarkSpacing(1);
// Set Y-axis options
yAxis.setCategoryType(AxisCategoryType.AUTOMATIC);
yAxis.setCrosses(AxisCrosses.MAXIMUM);
yAxis.setReverseOrder(true);
yAxis.setMajorTickMark(AxisTickMark.INSIDE);
yAxis.setMinorTickMark(AxisTickMark.CROSS);
yAxis.setMajorUnit(100.0);
yAxis.setMinorUnit(20.0);
yAxis.setTickLabelPosition(AxisTickLabelPosition.NEXT_TO_AXIS);getType | |
public int getType() | |
Example:
Shows an appropriate graph type for each chart series.
public void chartSeriesCollection() throws Exception {
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// There are 4 ways of populating a chart's series collection
// 1: Each series has a string array of categories, each with a corresponding data value
// Some of the other possible applications are bar, column, line and surface charts
Chart chart = appendChart(builder, ChartType.COLUMN, 300.0, 300.0);
// Create and name 3 categories with a string array
String[] categories = {"Category 1", "Category 2", "Category 3"};
// Create 2 series of data, each with one point for every category
// This will generate a column graph with 3 clusters of 2 bars
chart.getSeries().add("Series 1", categories, new double[]{76.6, 82.1, 91.6});
chart.getSeries().add("Series 2", categories, new double[]{64.2, 79.5, 94.0});
// Categories are distributed along the X-axis while values are distributed along the Y-axis
Assert.assertEquals(chart.getAxisX().getType(), ChartAxisType.CATEGORY);
Assert.assertEquals(chart.getAxisY().getType(), ChartAxisType.VALUE);
// 2: Each series will have a collection of dates with a corresponding value for each date
// Area, radar and stock charts are some of the appropriate chart types for this
chart = appendChart(builder, ChartType.AREA, 300.0, 300.0);
// Create a collection of dates to serve as categories
Date[] dates = {DocumentHelper.createDate(2014, 3, 31),
DocumentHelper.createDate(2017, 1, 23),
DocumentHelper.createDate(2017, 6, 18),
DocumentHelper.createDate(2019, 11, 22),
DocumentHelper.createDate(2020, 9, 7)
};
// Add one series with one point for each date
// Our sporadic dates will be distributed along the X-axis in a linear fashion
chart.getSeries().add("Series 1", dates, new double[]{15.8, 21.5, 22.9, 28.7, 33.1});
// 3: Each series will take two data arrays
// Appropriate for scatter plots
chart = appendChart(builder, ChartType.SCATTER, 300.0, 300.0);
// In each series, the first array contains the X-coordinates and the second contains respective Y-coordinates of points
chart.getSeries().add("Series 1", new double[]{3.1, 3.5, 6.3, 4.1, 2.2, 8.3, 1.2, 3.6}, new double[]{3.1, 6.3, 4.6, 0.9, 8.5, 4.2, 2.3, 9.9});
chart.getSeries().add("Series 2", new double[]{2.6, 7.3, 4.5, 6.6, 2.1, 9.3, 0.7, 3.3}, new double[]{7.1, 6.6, 3.5, 7.8, 7.7, 9.5, 1.3, 4.6});
// Both axes are value axes in this case
Assert.assertEquals(chart.getAxisX().getType(), ChartAxisType.VALUE);
Assert.assertEquals(chart.getAxisY().getType(), ChartAxisType.VALUE);
// 4: Each series will be built from three data arrays, used for bubble charts
chart = appendChart(builder, ChartType.BUBBLE, 300.0, 300.0);
// The first two arrays contain X/Y coordinates like above and the third determines the thickness of each point
chart.getSeries().add("Series 1", new double[]{1.1, 5.0, 9.8}, new double[]{1.2, 4.9, 9.9}, new double[]{2.0, 4.0, 8.0});
doc.save(getArtifactsDir() + "Charts.ChartSeriesCollection.docx");
}
/// <summary>
/// Get the DocumentBuilder to insert a chart of a specified ChartType, width and height and clean out its default data
/// </summary>
private Chart appendChart(DocumentBuilder builder, /*ChartType*/int chartType, double width, double height) throws Exception {
Shape chartShape = builder.insertChart(chartType, width, height);
Chart chart = chartShape.getChart();
chart.getSeries().clear();
Assert.assertEquals(chart.getSeries().getCount(), 0);
return chart;
}