com.aspose.words

Class AxisScaling

  • java.lang.Object
    • com.aspose.words.AxisScaling
  • All Implemented Interfaces:
    java.lang.Cloneable
    public class AxisScaling 
    extends java.lang.Object

Represents the scaling options of the axis.

Example:

Shows how to apply logarithmic scaling to a chart axis.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Add a scatter chart, and then clear its demo data series to start with a clean chart.
Shape chartShape = builder.insertChart(ChartType.SCATTER, 450.0, 300.0);
Chart chart = chartShape.getChart();
chart.getSeries().clear();

// Insert a series with X/Y coordinates for five points.
chart.getSeries().add("Series 1", 
    new double[] { 1.0, 2.0, 3.0, 4.0, 5.0 }, 
    new double[] { 1.0, 20.0, 400.0, 8000.0, 160000.0 });

// The scaling of the X-axis is linear by default,
// displaying evenly incrementing values that cover our X-value range (0, 1, 2, 3...).
// A linear axis is not ideal for our Y-values
// since the points with the smaller Y-values will be harder to read.
// A logarithmic scaling with a base of 20 (1, 20, 400, 8000...)
// will spread the plotted points, allowing us to read their values on the chart more easily.
chart.getAxisY().getScaling().setType(AxisScaleType.LOGARITHMIC);
chart.getAxisY().getScaling().setLogBase(20.0);

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

Constructor Summary
 
Property Getters/Setters Summary
doublegetLogBase()
void
setLogBase(doublevalue)
           Gets or sets the logarithmic base for a logarithmic axis.
AxisBoundgetMaximum()
void
           Gets or sets the maximum value of the axis.
AxisBoundgetMinimum()
void
           Gets or sets minimum value of the axis.
intgetType()
void
setType(intvalue)
           Gets or sets scaling type of the axis. The value of the property is AxisScaleType integer constant.
 

    • Constructor Detail

      • AxisScaling

        public AxisScaling()
    • Property Getters/Setters Detail

      • getLogBase/setLogBase

        public double getLogBase() / public void setLogBase(double value)
        
        Gets or sets the logarithmic base for a logarithmic axis.

        The property is not supported by MS Office 2016 new charts.

        Valid range of a floating point value is greater than or equal to 2 and less than or equal to 1000. The property has effect only if Type is set to AxisScaleType.LOGARITHMIC.

        Setting this property sets the Type property to AxisScaleType.LOGARITHMIC.

        Example:

        Shows how to apply logarithmic scaling to a chart axis.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Add a scatter chart, and then clear its demo data series to start with a clean chart.
        Shape chartShape = builder.insertChart(ChartType.SCATTER, 450.0, 300.0);
        Chart chart = chartShape.getChart();
        chart.getSeries().clear();
        
        // Insert a series with X/Y coordinates for five points.
        chart.getSeries().add("Series 1", 
            new double[] { 1.0, 2.0, 3.0, 4.0, 5.0 }, 
            new double[] { 1.0, 20.0, 400.0, 8000.0, 160000.0 });
        
        // The scaling of the X-axis is linear by default,
        // displaying evenly incrementing values that cover our X-value range (0, 1, 2, 3...).
        // A linear axis is not ideal for our Y-values
        // since the points with the smaller Y-values will be harder to read.
        // A logarithmic scaling with a base of 20 (1, 20, 400, 8000...)
        // will spread the plotted points, allowing us to read their values on the chart more easily.
        chart.getAxisY().getScaling().setType(AxisScaleType.LOGARITHMIC);
        chart.getAxisY().getScaling().setLogBase(20.0);
        
        doc.save(getArtifactsDir() + "Charts.AxisScaling.docx");
      • getMaximum/setMaximum

        public AxisBound getMaximum() / public void setMaximum(AxisBound value)
        
        Gets or sets the maximum value of the axis. The default value is "auto".

        Example:

        Shows how to insert chart with date/time values.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Add a line chart, and clear its demo data series to start with a clean chart.
        Shape shape = builder.insertChart(ChartType.LINE, 500.0, 300.0);
        Chart chart = shape.getChart();
        chart.getSeries().clear();
        
        // Add a custom series containing date/time values for the X-axis, and respective decimal values for the Y-axis.
        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});
        
        // Set lower and upper bounds for the X-axis.
        ChartAxis xAxis = chart.getAxisX();
        xAxis.getScaling().setMinimum(new AxisBound(DocumentHelper.createDate(2017, 11, 5)));
        xAxis.getScaling().setMaximum(new AxisBound(DocumentHelper.createDate(2017, 12, 3)));
        
        // Set the major units of the X-axis to a week, and the minor units to a day.
        xAxis.setBaseTimeUnit(AxisTimeUnit.DAYS);
        xAxis.setMajorUnit(7.0d);
        xAxis.setMajorTickMark(AxisTickMark.CROSS);
        xAxis.setMinorUnit(1.0d);
        xAxis.setMinorTickMark(AxisTickMark.OUTSIDE);
        
        // Define Y-axis properties for decimal values.
        ChartAxis yAxis = chart.getAxisY();
        yAxis.setTickLabelPosition(AxisTickLabelPosition.HIGH);
        yAxis.setMajorUnit(100.0d);
        yAxis.setMinorUnit(50.0d);
        yAxis.getDisplayUnit().setUnit(AxisBuiltInUnit.HUNDREDS);
        yAxis.getScaling().setMinimum(new AxisBound(100.0));
        yAxis.getScaling().setMaximum(new AxisBound(700.0));
        
        doc.save(getArtifactsDir() + "Charts.DateTimeValues.docx");
      • getMinimum/setMinimum

        public AxisBound getMinimum() / public void setMinimum(AxisBound value)
        
        Gets or sets minimum value of the axis. The default value is "auto".

        Example:

        Shows how to insert chart with date/time values.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Add a line chart, and clear its demo data series to start with a clean chart.
        Shape shape = builder.insertChart(ChartType.LINE, 500.0, 300.0);
        Chart chart = shape.getChart();
        chart.getSeries().clear();
        
        // Add a custom series containing date/time values for the X-axis, and respective decimal values for the Y-axis.
        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});
        
        // Set lower and upper bounds for the X-axis.
        ChartAxis xAxis = chart.getAxisX();
        xAxis.getScaling().setMinimum(new AxisBound(DocumentHelper.createDate(2017, 11, 5)));
        xAxis.getScaling().setMaximum(new AxisBound(DocumentHelper.createDate(2017, 12, 3)));
        
        // Set the major units of the X-axis to a week, and the minor units to a day.
        xAxis.setBaseTimeUnit(AxisTimeUnit.DAYS);
        xAxis.setMajorUnit(7.0d);
        xAxis.setMajorTickMark(AxisTickMark.CROSS);
        xAxis.setMinorUnit(1.0d);
        xAxis.setMinorTickMark(AxisTickMark.OUTSIDE);
        
        // Define Y-axis properties for decimal values.
        ChartAxis yAxis = chart.getAxisY();
        yAxis.setTickLabelPosition(AxisTickLabelPosition.HIGH);
        yAxis.setMajorUnit(100.0d);
        yAxis.setMinorUnit(50.0d);
        yAxis.getDisplayUnit().setUnit(AxisBuiltInUnit.HUNDREDS);
        yAxis.getScaling().setMinimum(new AxisBound(100.0));
        yAxis.getScaling().setMaximum(new AxisBound(700.0));
        
        doc.save(getArtifactsDir() + "Charts.DateTimeValues.docx");
      • getType/setType

        public int getType() / public void setType(int value)
        
        Gets or sets scaling type of the axis. The value of the property is AxisScaleType integer constant. The AxisScaleType.LINEAR value is the only that is allowed in MS Office 2016 new charts.

        Example:

        Shows how to apply logarithmic scaling to a chart axis.
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        // Add a scatter chart, and then clear its demo data series to start with a clean chart.
        Shape chartShape = builder.insertChart(ChartType.SCATTER, 450.0, 300.0);
        Chart chart = chartShape.getChart();
        chart.getSeries().clear();
        
        // Insert a series with X/Y coordinates for five points.
        chart.getSeries().add("Series 1", 
            new double[] { 1.0, 2.0, 3.0, 4.0, 5.0 }, 
            new double[] { 1.0, 20.0, 400.0, 8000.0, 160000.0 });
        
        // The scaling of the X-axis is linear by default,
        // displaying evenly incrementing values that cover our X-value range (0, 1, 2, 3...).
        // A linear axis is not ideal for our Y-values
        // since the points with the smaller Y-values will be harder to read.
        // A logarithmic scaling with a base of 20 (1, 20, 400, 8000...)
        // will spread the plotted points, allowing us to read their values on the chart more easily.
        chart.getAxisY().getScaling().setType(AxisScaleType.LOGARITHMIC);
        chart.getAxisY().getScaling().setLogBase(20.0);
        
        doc.save(getArtifactsDir() + "Charts.AxisScaling.docx");