java.lang.Object
com.aspose.words.AxisScaling
public class AxisScaling
To learn more, visit the Working with Charts documentation article. Example:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape chartShape = builder.insertChart(ChartType.SCATTER, 450.0, 300.0);
Chart chart = chartShape.getChart();
// Clear the chart's demo data series to start with a clean chart.
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 |
|---|
AxisScaling()
|
| Property Getters/Setters Summary | ||
|---|---|---|
double | getLogBase() | |
void | setLogBase(double value) | |
| Gets or sets the logarithmic base for a logarithmic axis. | ||
AxisBound | getMaximum() | |
void | setMaximum(AxisBound value) | |
| Gets or sets the maximum value of the axis. | ||
AxisBound | getMinimum() | |
void | setMinimum(AxisBound value) | |
| Gets or sets minimum value of the axis. | ||
int | getType() | |
void | setType(int value) | |
| Gets or sets scaling type of the axis. The value of the property is AxisScaleType integer constant. | ||
| Constructor Detail |
|---|
public AxisScaling()
| Property Getters/Setters Detail |
|---|
getLogBase/setLogBase | |
public double getLogBase() / public void setLogBase(double value) | |
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
Setting this property sets the
Example:
Shows how to apply logarithmic scaling to a chart axis.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape chartShape = builder.insertChart(ChartType.SCATTER, 450.0, 300.0);
Chart chart = chartShape.getChart();
// Clear the chart's demo data series to start with a clean chart.
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) | |
Example:
Shows how to insert chart with date/time values.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.LINE, 500.0, 300.0);
Chart chart = shape.getChart();
// Clear the chart's demo data series to start with a clean chart.
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();
Date datetimeMin = DocumentHelper.createDate(2017, 11, 5);
xAxis.getScaling().setMinimum(new AxisBound(datetimeMin));
Date datetimeMax = DocumentHelper.createDate(2017, 12, 3);
xAxis.getScaling().setMaximum(new AxisBound(datetimeMax));
// 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);
xAxis.hasMajorGridlines(true);
xAxis.hasMinorGridlines(true);
// Define Y-axis properties for decimal values.
ChartAxis yAxis = chart.getAxisY();
yAxis.getTickLabels().setPosition(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));
yAxis.hasMajorGridlines(true);
yAxis.hasMinorGridlines(true);
doc.save(getArtifactsDir() + "Charts.DateTimeValues.docx");getMinimum/setMinimum | |
public AxisBound getMinimum() / public void setMinimum(AxisBound value) | |
Example:
Shows how to insert chart with date/time values.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape shape = builder.insertChart(ChartType.LINE, 500.0, 300.0);
Chart chart = shape.getChart();
// Clear the chart's demo data series to start with a clean chart.
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();
Date datetimeMin = DocumentHelper.createDate(2017, 11, 5);
xAxis.getScaling().setMinimum(new AxisBound(datetimeMin));
Date datetimeMax = DocumentHelper.createDate(2017, 12, 3);
xAxis.getScaling().setMaximum(new AxisBound(datetimeMax));
// 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);
xAxis.hasMajorGridlines(true);
xAxis.hasMinorGridlines(true);
// Define Y-axis properties for decimal values.
ChartAxis yAxis = chart.getAxisY();
yAxis.getTickLabels().setPosition(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));
yAxis.hasMajorGridlines(true);
yAxis.hasMinorGridlines(true);
doc.save(getArtifactsDir() + "Charts.DateTimeValues.docx");getType/setType | |
public int getType() / public void setType(int value) | |
Example:
Shows how to apply logarithmic scaling to a chart axis.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
Shape chartShape = builder.insertChart(ChartType.SCATTER, 450.0, 300.0);
Chart chart = chartShape.getChart();
// Clear the chart's demo data series to start with a clean chart.
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");