public class AxisDisplayUnit
Example:
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, and configure them to both be inside the graph plot area. axis = chart.getAxisX(); axis.setMajorTickMark(AxisTickMark.INSIDE); axis.setMinorTickMark(AxisTickMark.INSIDE); axis.setMajorUnit(10.0); axis.setMinorUnit(2.5); // 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.setTickLabelAlignment(ParagraphAlignment.RIGHT); Assert.assertEquals(1, axis.getTickLabelSpacing()); // 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");
Constructor Summary |
---|
Property Getters/Setters Summary | ||
---|---|---|
double | getCustomUnit() | |
void | setCustomUnit(doublevalue) | |
Gets or sets a user-defined divisor to scale display units on the value axis. | ||
DocumentBase | getDocument() | |
Returns the Document the title holder belongs.
|
||
int | getUnit() | |
void | setUnit(intvalue) | |
Gets or sets the scaling value of the display units as one of the predefined values. The value of the property is AxisBuiltInUnit integer constant. |
public double getCustomUnit() / public void setCustomUnit(double value)
The property is not supported by MS Office 2016 new charts. Default value is 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); 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, and configure them to both be inside the graph plot area. axis = chart.getAxisX(); axis.setMajorTickMark(AxisTickMark.INSIDE); axis.setMinorTickMark(AxisTickMark.INSIDE); axis.setMajorUnit(10.0); axis.setMinorUnit(2.5); // 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.setTickLabelAlignment(ParagraphAlignment.RIGHT); Assert.assertEquals(1, axis.getTickLabelSpacing()); // 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");
public DocumentBase getDocument()
public int getUnit() / public void setUnit(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); 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, and configure them to both be inside the graph plot area. axis = chart.getAxisX(); axis.setMajorTickMark(AxisTickMark.INSIDE); axis.setMinorTickMark(AxisTickMark.INSIDE); axis.setMajorUnit(10.0); axis.setMinorUnit(2.5); // 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.setTickLabelAlignment(ParagraphAlignment.RIGHT); Assert.assertEquals(1, axis.getTickLabelSpacing()); // 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");