AxisDisplayUnit
Inheritance: java.lang.Object
All Implemented Interfaces: java.lang.Cloneable
public class AxisDisplayUnit implements Cloneable
Provides access to the scaling options of the display units for the value axis.
To learn more, visit the Working with Charts documentation article.
Examples:
Shows how to manipulate the tick marks and displayed values of a chart axis.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0);
Chart chart = shape.getChart();
Assert.assertEquals(1, chart.getSeries().getCount());
Assert.assertEquals("Y-Values", chart.getSeries().get(0).getName());
// Set the minor tick marks of the Y-axis to point away from the plot area,
// and the major tick marks to cross the axis.
ChartAxis axis = chart.getAxisY();
axis.setMajorTickMark(AxisTickMark.CROSS);
axis.setMinorTickMark(AxisTickMark.OUTSIDE);
// Set they Y-axis to show a major tick every 10 units, and a minor tick every 1 unit.
axis.setMajorUnit(10.0);
axis.setMinorUnit(1.0);
// Set the Y-axis bounds to -10 and 20.
// This Y-axis will now display 4 major tick marks and 27 minor tick marks.
axis.getScaling().setMinimum(new AxisBound(-10));
axis.getScaling().setMaximum(new AxisBound(20.0));
// For the X-axis, set the major tick marks at every 10 units,
// every minor tick mark at 2.5 units.
axis = chart.getAxisX();
axis.setMajorUnit(10.0);
axis.setMinorUnit(2.5);
// Configure both types of tick marks to appear inside the graph plot area.
axis.setMajorTickMark(AxisTickMark.INSIDE);
axis.setMinorTickMark(AxisTickMark.INSIDE);
// Set the X-axis bounds so that the X-axis spans 5 major tick marks and 12 minor tick marks.
axis.getScaling().setMinimum(new AxisBound(-10));
axis.getScaling().setMaximum(new AxisBound(30.0));
axis.getTickLabels().setAlignment(ParagraphAlignment.RIGHT);
Assert.assertEquals(1, axis.getTickLabels().getSpacing());
// Set the tick labels to display their value in millions.
axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS);
// We can set a more specific value by which tick labels will display their values.
// This statement is equivalent to the one above.
axis.getDisplayUnit().setCustomUnit(1000000.0);
doc.save(getArtifactsDir() + "Charts.AxisDisplayUnit.docx");
Methods
Method | Description |
---|---|
getCustomUnit() | Gets a user-defined divisor to scale display units on the value axis. |
getDefaultDisplayedFontSize() | |
getDefaultFontSize() | |
getDefaultTitleText() | |
getDocument() | Returns the document containing the parent chart. |
getRelativeFontSize(int chartFontSize) | |
getTitleDeleted() | |
getTitlePosition() | |
getUnit() | Gets the scaling value of the display units as one of the predefined values. |
isVisible() | |
setCustomUnit(double value) | Sets a user-defined divisor to scale display units on the value axis. |
setTitleDeleted(boolean value) | |
setUnit(int value) | Sets the scaling value of the display units as one of the predefined values. |
getCustomUnit()
public double getCustomUnit()
Gets a user-defined divisor to scale display units on the value axis.
Remarks:
The property is not supported by MS Office 2016 new charts. Default value is 1.
Setting this property sets the getUnit() / setUnit(int) property to AxisBuiltInUnit.CUSTOM.
Examples:
Shows how to manipulate the tick marks and displayed values of a chart axis.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0);
Chart chart = shape.getChart();
Assert.assertEquals(1, chart.getSeries().getCount());
Assert.assertEquals("Y-Values", chart.getSeries().get(0).getName());
// Set the minor tick marks of the Y-axis to point away from the plot area,
// and the major tick marks to cross the axis.
ChartAxis axis = chart.getAxisY();
axis.setMajorTickMark(AxisTickMark.CROSS);
axis.setMinorTickMark(AxisTickMark.OUTSIDE);
// Set they Y-axis to show a major tick every 10 units, and a minor tick every 1 unit.
axis.setMajorUnit(10.0);
axis.setMinorUnit(1.0);
// Set the Y-axis bounds to -10 and 20.
// This Y-axis will now display 4 major tick marks and 27 minor tick marks.
axis.getScaling().setMinimum(new AxisBound(-10));
axis.getScaling().setMaximum(new AxisBound(20.0));
// For the X-axis, set the major tick marks at every 10 units,
// every minor tick mark at 2.5 units.
axis = chart.getAxisX();
axis.setMajorUnit(10.0);
axis.setMinorUnit(2.5);
// Configure both types of tick marks to appear inside the graph plot area.
axis.setMajorTickMark(AxisTickMark.INSIDE);
axis.setMinorTickMark(AxisTickMark.INSIDE);
// Set the X-axis bounds so that the X-axis spans 5 major tick marks and 12 minor tick marks.
axis.getScaling().setMinimum(new AxisBound(-10));
axis.getScaling().setMaximum(new AxisBound(30.0));
axis.getTickLabels().setAlignment(ParagraphAlignment.RIGHT);
Assert.assertEquals(1, axis.getTickLabels().getSpacing());
// Set the tick labels to display their value in millions.
axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS);
// We can set a more specific value by which tick labels will display their values.
// This statement is equivalent to the one above.
axis.getDisplayUnit().setCustomUnit(1000000.0);
doc.save(getArtifactsDir() + "Charts.AxisDisplayUnit.docx");
Returns: double - A user-defined divisor to scale display units on the value axis.
getDefaultDisplayedFontSize()
public double getDefaultDisplayedFontSize()
Returns: double
getDefaultFontSize()
public double getDefaultFontSize()
Returns: double
getDefaultTitleText()
public String getDefaultTitleText()
Returns: java.lang.String
getDocument()
public DocumentBase getDocument()
Returns the document containing the parent chart.
Returns: DocumentBase - The document containing the parent chart.
getRelativeFontSize(int chartFontSize)
public int getRelativeFontSize(int chartFontSize)
Parameters:
Parameter | Type | Description |
---|---|---|
chartFontSize | int |
Returns: int
getTitleDeleted()
public boolean getTitleDeleted()
Returns: boolean
getTitlePosition()
public int getTitlePosition()
Returns: int
getUnit()
public int getUnit()
Gets the scaling value of the display units as one of the predefined values.
Remarks:
Default value is AxisBuiltInUnit.NONE. The AxisBuiltInUnit.CUSTOM and AxisBuiltInUnit.PERCENTAGE values are not available in some chart types; see AxisBuiltInUnit for more information.
Examples:
Shows how to manipulate the tick marks and displayed values of a chart axis.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0);
Chart chart = shape.getChart();
Assert.assertEquals(1, chart.getSeries().getCount());
Assert.assertEquals("Y-Values", chart.getSeries().get(0).getName());
// Set the minor tick marks of the Y-axis to point away from the plot area,
// and the major tick marks to cross the axis.
ChartAxis axis = chart.getAxisY();
axis.setMajorTickMark(AxisTickMark.CROSS);
axis.setMinorTickMark(AxisTickMark.OUTSIDE);
// Set they Y-axis to show a major tick every 10 units, and a minor tick every 1 unit.
axis.setMajorUnit(10.0);
axis.setMinorUnit(1.0);
// Set the Y-axis bounds to -10 and 20.
// This Y-axis will now display 4 major tick marks and 27 minor tick marks.
axis.getScaling().setMinimum(new AxisBound(-10));
axis.getScaling().setMaximum(new AxisBound(20.0));
// For the X-axis, set the major tick marks at every 10 units,
// every minor tick mark at 2.5 units.
axis = chart.getAxisX();
axis.setMajorUnit(10.0);
axis.setMinorUnit(2.5);
// Configure both types of tick marks to appear inside the graph plot area.
axis.setMajorTickMark(AxisTickMark.INSIDE);
axis.setMinorTickMark(AxisTickMark.INSIDE);
// Set the X-axis bounds so that the X-axis spans 5 major tick marks and 12 minor tick marks.
axis.getScaling().setMinimum(new AxisBound(-10));
axis.getScaling().setMaximum(new AxisBound(30.0));
axis.getTickLabels().setAlignment(ParagraphAlignment.RIGHT);
Assert.assertEquals(1, axis.getTickLabels().getSpacing());
// Set the tick labels to display their value in millions.
axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS);
// We can set a more specific value by which tick labels will display their values.
// This statement is equivalent to the one above.
axis.getDisplayUnit().setCustomUnit(1000000.0);
doc.save(getArtifactsDir() + "Charts.AxisDisplayUnit.docx");
Returns: int - The scaling value of the display units as one of the predefined values. The returned value is one of AxisBuiltInUnit constants.
isVisible()
public boolean isVisible()
Returns: boolean
setCustomUnit(double value)
public void setCustomUnit(double value)
Sets a user-defined divisor to scale display units on the value axis.
Remarks:
The property is not supported by MS Office 2016 new charts. Default value is 1.
Setting this property sets the getUnit() / setUnit(int) property to AxisBuiltInUnit.CUSTOM.
Examples:
Shows how to manipulate the tick marks and displayed values of a chart axis.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0);
Chart chart = shape.getChart();
Assert.assertEquals(1, chart.getSeries().getCount());
Assert.assertEquals("Y-Values", chart.getSeries().get(0).getName());
// Set the minor tick marks of the Y-axis to point away from the plot area,
// and the major tick marks to cross the axis.
ChartAxis axis = chart.getAxisY();
axis.setMajorTickMark(AxisTickMark.CROSS);
axis.setMinorTickMark(AxisTickMark.OUTSIDE);
// Set they Y-axis to show a major tick every 10 units, and a minor tick every 1 unit.
axis.setMajorUnit(10.0);
axis.setMinorUnit(1.0);
// Set the Y-axis bounds to -10 and 20.
// This Y-axis will now display 4 major tick marks and 27 minor tick marks.
axis.getScaling().setMinimum(new AxisBound(-10));
axis.getScaling().setMaximum(new AxisBound(20.0));
// For the X-axis, set the major tick marks at every 10 units,
// every minor tick mark at 2.5 units.
axis = chart.getAxisX();
axis.setMajorUnit(10.0);
axis.setMinorUnit(2.5);
// Configure both types of tick marks to appear inside the graph plot area.
axis.setMajorTickMark(AxisTickMark.INSIDE);
axis.setMinorTickMark(AxisTickMark.INSIDE);
// Set the X-axis bounds so that the X-axis spans 5 major tick marks and 12 minor tick marks.
axis.getScaling().setMinimum(new AxisBound(-10));
axis.getScaling().setMaximum(new AxisBound(30.0));
axis.getTickLabels().setAlignment(ParagraphAlignment.RIGHT);
Assert.assertEquals(1, axis.getTickLabels().getSpacing());
// Set the tick labels to display their value in millions.
axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS);
// We can set a more specific value by which tick labels will display their values.
// This statement is equivalent to the one above.
axis.getDisplayUnit().setCustomUnit(1000000.0);
doc.save(getArtifactsDir() + "Charts.AxisDisplayUnit.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | double | A user-defined divisor to scale display units on the value axis. |
setTitleDeleted(boolean value)
public void setTitleDeleted(boolean value)
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean |
setUnit(int value)
public void setUnit(int value)
Sets the scaling value of the display units as one of the predefined values.
Remarks:
Default value is AxisBuiltInUnit.NONE. The AxisBuiltInUnit.CUSTOM and AxisBuiltInUnit.PERCENTAGE values are not available in some chart types; see AxisBuiltInUnit for more information.
Examples:
Shows how to manipulate the tick marks and displayed values of a chart axis.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.SCATTER, 450.0, 250.0);
Chart chart = shape.getChart();
Assert.assertEquals(1, chart.getSeries().getCount());
Assert.assertEquals("Y-Values", chart.getSeries().get(0).getName());
// Set the minor tick marks of the Y-axis to point away from the plot area,
// and the major tick marks to cross the axis.
ChartAxis axis = chart.getAxisY();
axis.setMajorTickMark(AxisTickMark.CROSS);
axis.setMinorTickMark(AxisTickMark.OUTSIDE);
// Set they Y-axis to show a major tick every 10 units, and a minor tick every 1 unit.
axis.setMajorUnit(10.0);
axis.setMinorUnit(1.0);
// Set the Y-axis bounds to -10 and 20.
// This Y-axis will now display 4 major tick marks and 27 minor tick marks.
axis.getScaling().setMinimum(new AxisBound(-10));
axis.getScaling().setMaximum(new AxisBound(20.0));
// For the X-axis, set the major tick marks at every 10 units,
// every minor tick mark at 2.5 units.
axis = chart.getAxisX();
axis.setMajorUnit(10.0);
axis.setMinorUnit(2.5);
// Configure both types of tick marks to appear inside the graph plot area.
axis.setMajorTickMark(AxisTickMark.INSIDE);
axis.setMinorTickMark(AxisTickMark.INSIDE);
// Set the X-axis bounds so that the X-axis spans 5 major tick marks and 12 minor tick marks.
axis.getScaling().setMinimum(new AxisBound(-10));
axis.getScaling().setMaximum(new AxisBound(30.0));
axis.getTickLabels().setAlignment(ParagraphAlignment.RIGHT);
Assert.assertEquals(1, axis.getTickLabels().getSpacing());
// Set the tick labels to display their value in millions.
axis.getDisplayUnit().setUnit(AxisBuiltInUnit.MILLIONS);
// We can set a more specific value by which tick labels will display their values.
// This statement is equivalent to the one above.
axis.getDisplayUnit().setCustomUnit(1000000.0);
doc.save(getArtifactsDir() + "Charts.AxisDisplayUnit.docx");
Parameters:
Parameter | Type | Description |
---|---|---|
value | int | The scaling value of the display units as one of the predefined values. The value must be one of AxisBuiltInUnit constants. |