AxisTimeUnit

Inheritance: java.lang.Object

public class AxisTimeUnit

Specifies the unit of time for axes.

Examples:

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

Fields

FieldDescription
AUTOMATICSpecifies that unit was not set explicitly and default value should be used.
DAYSSpecifies that the chart data shall be shown in days.
MONTHSSpecifies that the chart data shall be shown in months.
YEARSSpecifies that the chart data shall be shown in years.
length

Methods

MethodDescription
fromName(String axisTimeUnitName)
getName(int axisTimeUnit)
getValues()
toString(int axisTimeUnit)

AUTOMATIC

public static int AUTOMATIC

Specifies that unit was not set explicitly and default value should be used.

DAYS

public static int DAYS

Specifies that the chart data shall be shown in days.

MONTHS

public static int MONTHS

Specifies that the chart data shall be shown in months.

YEARS

public static int YEARS

Specifies that the chart data shall be shown in years.

length

public static int length

fromName(String axisTimeUnitName)

public static int fromName(String axisTimeUnitName)

Parameters:

ParameterTypeDescription
axisTimeUnitNamejava.lang.String

Returns: int

getName(int axisTimeUnit)

public static String getName(int axisTimeUnit)

Parameters:

ParameterTypeDescription
axisTimeUnitint

Returns: java.lang.String

getValues()

public static int[] getValues()

Returns: int[]

toString(int axisTimeUnit)

public static String toString(int axisTimeUnit)

Parameters:

ParameterTypeDescription
axisTimeUnitint

Returns: java.lang.String