AxisBound class
AxisBound class
Represents minimum or maximum bound of axis values. To learn more, visit the Working with Charts documentation article.
Remarks
Bound can be specified as a numeric, datetime or a special “auto” value.
The instances of this class are immutable.
Constructors
| Name | Description |
|---|---|
| AxisBound() | Creates a new instance indicating that axis bound should be determined automatically by a word-processing application. |
| AxisBound(value) | Creates an axis bound represented as a number. |
| AxisBound(datetime) | Creates an axis bound represented as datetime value. |
Properties
| Name | Description |
|---|---|
| is_auto | Returns a flag indicating that axis bound should be determined automatically. |
| value | Returns numeric value of axis bound. |
| value_as_date | Returns value of axis bound represented as datetime. |
Examples
Shows how to insert chart with date/time values.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
shape = builder.insert_chart(chart_type=aw.drawing.charts.ChartType.LINE, width=500, height=300)
chart = shape.chart
# Clear the chart's demo data series to start with a clean chart.
chart.series.clear()
# Add a custom series containing date/time values for the X-axis, and respective decimal values for the Y-axis.
chart.series.add_date(series_name='Aspose Test Series', dates=[datetime.datetime(2017, 11, 6), datetime.datetime(2017, 11, 9), datetime.datetime(2017, 11, 15), datetime.datetime(2017, 11, 21), datetime.datetime(2017, 11, 25), datetime.datetime(2017, 11, 29)], values=[1.2, 0.3, 2.1, 2.9, 4.2, 5.3])
# Set lower and upper bounds for the X-axis.
x_axis = chart.axis_x
# Convert datetime to OLE Automation date (days since 1899-12-30)
def to_ole_autodate(dt):
# Days from 0001-01-01 to 1899-12-30 is 693594
delta = dt - datetime.datetime(1899, 12, 30)
return delta.days + (dt.hour * 3600 + dt.minute * 60 + dt.second) / 86400.0
x_axis.scaling.minimum = aw.drawing.charts.AxisBound(to_ole_autodate(datetime.datetime(2017, 11, 5)))
x_axis.scaling.maximum = aw.drawing.charts.AxisBound(to_ole_autodate(datetime.datetime(2017, 12, 3)))
# Set the major units of the X-axis to a week, and the minor units to a day.
x_axis.base_time_unit = aw.drawing.charts.AxisTimeUnit.DAYS
x_axis.major_unit = 7
x_axis.major_tick_mark = aw.drawing.charts.AxisTickMark.CROSS
x_axis.minor_unit = 1
x_axis.minor_tick_mark = aw.drawing.charts.AxisTickMark.OUTSIDE
x_axis.has_major_gridlines = True
x_axis.has_minor_gridlines = True
# Define Y-axis properties for decimal values.
y_axis = chart.axis_y
y_axis.tick_labels.position = aw.drawing.charts.AxisTickLabelPosition.HIGH
y_axis.major_unit = 100
y_axis.minor_unit = 50
y_axis.display_unit.unit = aw.drawing.charts.AxisBuiltInUnit.HUNDREDS
y_axis.scaling.minimum = aw.drawing.charts.AxisBound(100)
y_axis.scaling.maximum = aw.drawing.charts.AxisBound(700)
y_axis.has_major_gridlines = True
y_axis.has_minor_gridlines = True
doc.save(file_name=ARTIFACTS_DIR + 'Charts.DateTimeValues.docx')
See Also
- module aspose.words.drawing.charts
- property AxisScaling.minimum
- property AxisScaling.maximum