com.aspose.words
Class AxisBound

java.lang.Object
    extended by com.aspose.words.AxisBound

public class AxisBound 
extends java.lang.Object

Represents minimum or maximum bound of axis values.

Bound can be specified as a numeric, datetime or a special "auto" value.

The instances of this class are immutable.

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");
See Also:
AxisScaling.Minimum, AxisScaling.Maximum

Constructor Summary
AxisBound()
           Creates a new instance indicating that axis bound should be determined automatically by a word-processing application.
AxisBound(double value)
           Creates an axis bound represented as a number.
AxisBound(java.util.Date datetime)
           Creates an axis bound represented as datetime value.
 
Property Getters/Setters Summary
booleanisAuto()
           Returns a flag indicating that axis bound should be determined automatically.
doublegetValue()
           Returns numeric value of axis bound.
java.util.DategetValueAsDate()
           Returns value of axis bound represented as datetime.
 
Method Summary
booleanequals(java.lang.Object obj)
           Determines whether the specified object is equal in value to the current object.
inthashCode()
           Serves as a hash function for this type.
java.lang.StringtoString()
           Returns a user-friendly string that displays the value of this object.
 

Constructor Detail

AxisBound

public AxisBound()
Creates a new instance indicating that axis bound should be determined automatically by a word-processing application.

Example:

Shows how to set custom axis bounds.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a scatter chart, remove default data and populate it with data from a ChartSeries
Shape chartShape = builder.insertChart(ChartType.SCATTER, 450.0, 300.0);
Chart chart = chartShape.getChart();
chart.getSeries().clear();
chart.getSeries().add("Series 1", new double[]{1.1, 5.4, 7.9, 3.5, 2.1, 9.7}, new double[]{2.1, 0.3, 0.6, 3.3, 1.4, 1.9});

// By default, the axis bounds are automatically defined so all the series data within the table is included
Assert.assertTrue(chart.getAxisX().getScaling().getMinimum().isAuto());

// If we wish to set our own scale bounds, we need to replace them with new ones
// Both the axis rulers will go from 0 to 10
chart.getAxisX().getScaling().setMinimum(new AxisBound(0.0));
chart.getAxisX().getScaling().setMaximum(new AxisBound(10.0));
chart.getAxisY().getScaling().setMinimum(new AxisBound(0.0));
chart.getAxisY().getScaling().setMaximum(new AxisBound(10.0));

// These are custom and not defined automatically
Assert.assertFalse(chart.getAxisX().getScaling().getMinimum().isAuto());
Assert.assertFalse(chart.getAxisY().getScaling().getMinimum().isAuto());

// Create a line graph
chartShape = builder.insertChart(ChartType.LINE, 450.0, 300.0);
chart = chartShape.getChart();
chart.getSeries().clear();

// Create a collection of dates, which will make up the X axis
Date[] dates = {DocumentHelper.createDate(1973, 5, 11),
        DocumentHelper.createDate(1981, 2, 4),
        DocumentHelper.createDate(1985, 9, 23),
        DocumentHelper.createDate(1989, 6, 28),
        DocumentHelper.createDate(1994, 12, 15)
};

// Assign a Y-value for each date 
chart.getSeries().add("Series 1", dates, new double[]{3.0, 4.7, 5.9, 7.1, 8.9});

// These particular bounds will cut off categories from before 1980 and from 1990 and onwards
// This narrows the amount of categories and values in the viewport from 5 to 3
// Note that the graph still contains the out-of-range data because we can see the line tend towards it
chart.getAxisX().getScaling().setMinimum(new AxisBound(DocumentHelper.createDate(1980, 1, 1)));
chart.getAxisX().getScaling().setMaximum(new AxisBound(DocumentHelper.createDate(1990, 1, 1)));

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

AxisBound

public AxisBound(double value)
Creates an axis bound represented as a number.

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");

AxisBound

public AxisBound(java.util.Date datetime)
Creates an axis bound represented as datetime 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.DateTimeValues.docx");

Property Getters/Setters Detail

isAuto

public boolean isAuto()
Returns a flag indicating that axis bound should be determined automatically.

Example:

Shows how to set custom axis bounds.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a scatter chart, remove default data and populate it with data from a ChartSeries
Shape chartShape = builder.insertChart(ChartType.SCATTER, 450.0, 300.0);
Chart chart = chartShape.getChart();
chart.getSeries().clear();
chart.getSeries().add("Series 1", new double[]{1.1, 5.4, 7.9, 3.5, 2.1, 9.7}, new double[]{2.1, 0.3, 0.6, 3.3, 1.4, 1.9});

// By default, the axis bounds are automatically defined so all the series data within the table is included
Assert.assertTrue(chart.getAxisX().getScaling().getMinimum().isAuto());

// If we wish to set our own scale bounds, we need to replace them with new ones
// Both the axis rulers will go from 0 to 10
chart.getAxisX().getScaling().setMinimum(new AxisBound(0.0));
chart.getAxisX().getScaling().setMaximum(new AxisBound(10.0));
chart.getAxisY().getScaling().setMinimum(new AxisBound(0.0));
chart.getAxisY().getScaling().setMaximum(new AxisBound(10.0));

// These are custom and not defined automatically
Assert.assertFalse(chart.getAxisX().getScaling().getMinimum().isAuto());
Assert.assertFalse(chart.getAxisY().getScaling().getMinimum().isAuto());

// Create a line graph
chartShape = builder.insertChart(ChartType.LINE, 450.0, 300.0);
chart = chartShape.getChart();
chart.getSeries().clear();

// Create a collection of dates, which will make up the X axis
Date[] dates = {DocumentHelper.createDate(1973, 5, 11),
        DocumentHelper.createDate(1981, 2, 4),
        DocumentHelper.createDate(1985, 9, 23),
        DocumentHelper.createDate(1989, 6, 28),
        DocumentHelper.createDate(1994, 12, 15)
};

// Assign a Y-value for each date 
chart.getSeries().add("Series 1", dates, new double[]{3.0, 4.7, 5.9, 7.1, 8.9});

// These particular bounds will cut off categories from before 1980 and from 1990 and onwards
// This narrows the amount of categories and values in the viewport from 5 to 3
// Note that the graph still contains the out-of-range data because we can see the line tend towards it
chart.getAxisX().getScaling().setMinimum(new AxisBound(DocumentHelper.createDate(1980, 1, 1)));
chart.getAxisX().getScaling().setMaximum(new AxisBound(DocumentHelper.createDate(1990, 1, 1)));

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

getValue

public double getValue()
Returns numeric value of axis bound.

Example:

Shows how to set custom axis bounds.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a scatter chart, remove default data and populate it with data from a ChartSeries
Shape chartShape = builder.insertChart(ChartType.SCATTER, 450.0, 300.0);
Chart chart = chartShape.getChart();
chart.getSeries().clear();
chart.getSeries().add("Series 1", new double[]{1.1, 5.4, 7.9, 3.5, 2.1, 9.7}, new double[]{2.1, 0.3, 0.6, 3.3, 1.4, 1.9});

// By default, the axis bounds are automatically defined so all the series data within the table is included
Assert.assertTrue(chart.getAxisX().getScaling().getMinimum().isAuto());

// If we wish to set our own scale bounds, we need to replace them with new ones
// Both the axis rulers will go from 0 to 10
chart.getAxisX().getScaling().setMinimum(new AxisBound(0.0));
chart.getAxisX().getScaling().setMaximum(new AxisBound(10.0));
chart.getAxisY().getScaling().setMinimum(new AxisBound(0.0));
chart.getAxisY().getScaling().setMaximum(new AxisBound(10.0));

// These are custom and not defined automatically
Assert.assertFalse(chart.getAxisX().getScaling().getMinimum().isAuto());
Assert.assertFalse(chart.getAxisY().getScaling().getMinimum().isAuto());

// Create a line graph
chartShape = builder.insertChart(ChartType.LINE, 450.0, 300.0);
chart = chartShape.getChart();
chart.getSeries().clear();

// Create a collection of dates, which will make up the X axis
Date[] dates = {DocumentHelper.createDate(1973, 5, 11),
        DocumentHelper.createDate(1981, 2, 4),
        DocumentHelper.createDate(1985, 9, 23),
        DocumentHelper.createDate(1989, 6, 28),
        DocumentHelper.createDate(1994, 12, 15)
};

// Assign a Y-value for each date 
chart.getSeries().add("Series 1", dates, new double[]{3.0, 4.7, 5.9, 7.1, 8.9});

// These particular bounds will cut off categories from before 1980 and from 1990 and onwards
// This narrows the amount of categories and values in the viewport from 5 to 3
// Note that the graph still contains the out-of-range data because we can see the line tend towards it
chart.getAxisX().getScaling().setMinimum(new AxisBound(DocumentHelper.createDate(1980, 1, 1)));
chart.getAxisX().getScaling().setMaximum(new AxisBound(DocumentHelper.createDate(1990, 1, 1)));

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

getValueAsDate

public java.util.Date getValueAsDate()
Returns value of axis bound represented as datetime.

Example:

Shows how to set custom axis bounds.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a scatter chart, remove default data and populate it with data from a ChartSeries
Shape chartShape = builder.insertChart(ChartType.SCATTER, 450.0, 300.0);
Chart chart = chartShape.getChart();
chart.getSeries().clear();
chart.getSeries().add("Series 1", new double[]{1.1, 5.4, 7.9, 3.5, 2.1, 9.7}, new double[]{2.1, 0.3, 0.6, 3.3, 1.4, 1.9});

// By default, the axis bounds are automatically defined so all the series data within the table is included
Assert.assertTrue(chart.getAxisX().getScaling().getMinimum().isAuto());

// If we wish to set our own scale bounds, we need to replace them with new ones
// Both the axis rulers will go from 0 to 10
chart.getAxisX().getScaling().setMinimum(new AxisBound(0.0));
chart.getAxisX().getScaling().setMaximum(new AxisBound(10.0));
chart.getAxisY().getScaling().setMinimum(new AxisBound(0.0));
chart.getAxisY().getScaling().setMaximum(new AxisBound(10.0));

// These are custom and not defined automatically
Assert.assertFalse(chart.getAxisX().getScaling().getMinimum().isAuto());
Assert.assertFalse(chart.getAxisY().getScaling().getMinimum().isAuto());

// Create a line graph
chartShape = builder.insertChart(ChartType.LINE, 450.0, 300.0);
chart = chartShape.getChart();
chart.getSeries().clear();

// Create a collection of dates, which will make up the X axis
Date[] dates = {DocumentHelper.createDate(1973, 5, 11),
        DocumentHelper.createDate(1981, 2, 4),
        DocumentHelper.createDate(1985, 9, 23),
        DocumentHelper.createDate(1989, 6, 28),
        DocumentHelper.createDate(1994, 12, 15)
};

// Assign a Y-value for each date 
chart.getSeries().add("Series 1", dates, new double[]{3.0, 4.7, 5.9, 7.1, 8.9});

// These particular bounds will cut off categories from before 1980 and from 1990 and onwards
// This narrows the amount of categories and values in the viewport from 5 to 3
// Note that the graph still contains the out-of-range data because we can see the line tend towards it
chart.getAxisX().getScaling().setMinimum(new AxisBound(DocumentHelper.createDate(1980, 1, 1)));
chart.getAxisX().getScaling().setMaximum(new AxisBound(DocumentHelper.createDate(1990, 1, 1)));

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

Method Detail

equals

public boolean equals(java.lang.Object obj)
Determines whether the specified object is equal in value to the current object.

hashCode

public int hashCode()
Serves as a hash function for this type.

toString

public java.lang.String toString()
Returns a user-friendly string that displays the value of this object.

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