com.aspose.words
Class AxisScaling

java.lang.Object
    extended by 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 set up logarithmic axis scaling.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a scatter chart and clear its default data series
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 5 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, which means it will display "0, 1, 2, 3..."
// Linear axis scaling is suitable for our X-values, but our Y-values call for a logarithmic scale to be represented accurately on a graph 
// We can set the scaling of the Y-axis to Logarithmic with a base of 20
// The Y-axis will now display "1, 20, 400, 8000...", which is ideal for accurate representation of this set of Y-values
chart.getAxisY().getScaling().setType(AxisScaleType.LOGARITHMIC);
chart.getAxisY().getScaling().setLogBase(20.0);

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

Constructor Summary
AxisScaling()
          
 
Property Getters/Setters Summary
doublegetLogBase()
voidsetLogBase(double value)
           Gets or sets the logarithmic base for a logarithmic axis.
AxisBoundgetMaximum()
voidsetMaximum(AxisBound value)
           Gets or sets the maximum value of the axis.
AxisBoundgetMinimum()
voidsetMinimum(AxisBound value)
           Gets or sets minimum value of the axis.
intgetType()
voidsetType(int value)
           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 set up logarithmic axis scaling.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a scatter chart and clear its default data series
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 5 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, which means it will display "0, 1, 2, 3..."
// Linear axis scaling is suitable for our X-values, but our Y-values call for a logarithmic scale to be represented accurately on a graph 
// We can set the scaling of the Y-axis to Logarithmic with a base of 20
// The Y-axis will now display "1, 20, 400, 8000...", which is ideal for accurate representation of this set of Y-values
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);

// 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.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);

// 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.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 set up logarithmic axis scaling.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a scatter chart and clear its default data series
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 5 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, which means it will display "0, 1, 2, 3..."
// Linear axis scaling is suitable for our X-values, but our Y-values call for a logarithmic scale to be represented accurately on a graph 
// We can set the scaling of the Y-axis to Logarithmic with a base of 20
// The Y-axis will now display "1, 20, 400, 8000...", which is ideal for accurate representation of this set of Y-values
chart.getAxisY().getScaling().setType(AxisScaleType.LOGARITHMIC);
chart.getAxisY().getScaling().setLogBase(20.0);

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

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.