insert_chart method
Contents
[
Hide
]insert_chart(chart_type, width, height)
Inserts an chart object into the document and scales it to the specified size.
def insert_chart(self, chart_type: aspose.words.drawing.charts.ChartType, width: float, height: float):
...
Parameter | Type | Description |
---|---|---|
chart_type | ChartType | The chart type to insert into the document. |
width | float | The width of the image in points. Can be a negative or zero value to request 100% scale. |
height | float | The height of the image in points. Can be a negative or zero value to request 100% scale. |
Remarks
You can change the image size, location, positioning method and other settings using the Shape object returned by this method.
Returns
The image node that was just inserted.
insert_chart(chart_type, horz_pos, left, vert_pos, top, width, height, wrap_type)
Inserts an chart object into the document and scales it to the specified size.
def insert_chart(self, chart_type: aspose.words.drawing.charts.ChartType, horz_pos: aspose.words.drawing.RelativeHorizontalPosition, left: float, vert_pos: aspose.words.drawing.RelativeVerticalPosition, top: float, width: float, height: float, wrap_type: aspose.words.drawing.WrapType):
...
Parameter | Type | Description |
---|---|---|
chart_type | ChartType | The chart type to insert into the document. |
horz_pos | RelativeHorizontalPosition | Specifies where the distance to the image is measured from. |
left | float | Distance in points from the origin to the left side of the image. |
vert_pos | RelativeVerticalPosition | Specifies where the distance to the image measured from. |
top | float | Distance in points from the origin to the top side of the image. |
width | float | The width of the image in points. Can be a negative or zero value to request 100% scale. |
height | float | The height of the image in points. Can be a negative or zero value to request 100% scale. |
wrap_type | WrapType | Specifies how to wrap text around the image. |
Remarks
You can change the image size, location, positioning method and other settings using the Shape object returned by this method.
Returns
The image node that was just inserted.
Examples
Shows how to insert a pie chart into a document.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
chart = builder.insert_chart(chart_type=aw.drawing.charts.ChartType.PIE, width=aw.ConvertUtil.pixel_to_point(pixels=300), height=aw.ConvertUtil.pixel_to_point(pixels=300)).chart
chart.series.clear()
chart.series.add(series_name='My fruit', categories=['Apples', 'Bananas', 'Cherries'], values=[1.3, 2.2, 1.5])
doc.save(file_name=ARTIFACTS_DIR + 'DocumentBuilder.InsertPieChart.docx')
Shows how to specify position and wrapping while inserting a chart.
doc = aw.Document()
builder = aw.DocumentBuilder(doc=doc)
builder.insert_chart(chart_type=aw.drawing.charts.ChartType.PIE, horz_pos=aw.drawing.RelativeHorizontalPosition.MARGIN, left=100, vert_pos=aw.drawing.RelativeVerticalPosition.MARGIN, top=100, width=200, height=100, wrap_type=aw.drawing.WrapType.SQUARE)
doc.save(file_name=ARTIFACTS_DIR + 'DocumentBuilder.InsertedChartRelativePosition.docx')
See Also
- module aspose.words
- class DocumentBuilder