insertChart method
Contents
[
Hide
]insertChart(chartType, width, height)
Inserts an chart object into the document and scales it to the specified size.
insertChart(chartType: Aspose.Words.Drawing.Charts.ChartType, width: number, height: number)
Parameter | Type | Description |
---|---|---|
chartType | ChartType | The chart type to insert into the document. |
width | number | The width of the image in points. Can be a negative or zero value to request 100% scale. |
height | number | 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.
insertChart(chartType, horzPos, left, vertPos, top, width, height, wrapType)
Inserts an chart object into the document and scales it to the specified size.
insertChart(chartType: Aspose.Words.Drawing.Charts.ChartType, horzPos: Aspose.Words.Drawing.RelativeHorizontalPosition, left: number, vertPos: Aspose.Words.Drawing.RelativeVerticalPosition, top: number, width: number, height: number, wrapType: Aspose.Words.Drawing.WrapType)
Parameter | Type | Description |
---|---|---|
chartType | ChartType | The chart type to insert into the document. |
horzPos | RelativeHorizontalPosition | Specifies where the distance to the image is measured from. |
left | number | Distance in points from the origin to the left side of the image. |
vertPos | RelativeVerticalPosition | Specifies where the distance to the image measured from. |
top | number | Distance in points from the origin to the top side of the image. |
width | number | The width of the image in points. Can be a negative or zero value to request 100% scale. |
height | number | The height of the image in points. Can be a negative or zero value to request 100% scale. |
wrapType | 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.
let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);
let chart = builder.insertChart(aw.Drawing.Charts.ChartType.Pie, aw.ConvertUtil.pixelToPoint(300),
aw.ConvertUtil.pixelToPoint(300)).chart;
expect(aw.ConvertUtil.pixelToPoint(300)).toEqual(225.0);
chart.series.clear();
chart.series.add("My fruit",
[ "Apples", "Bananas", "Cherries" ],
[ 1.3, 2.2, 1.5 ]);
doc.save(base.artifactsDir + "DocumentBuilder.InsertPieChart.docx");
Shows how to specify position and wrapping while inserting a chart.
let doc = new aw.Document();
let builder = new aw.DocumentBuilder(doc);
builder.insertChart(aw.Drawing.Charts.ChartType.Pie, aw.Drawing.RelativeHorizontalPosition.Margin, 100, aw.Drawing.RelativeVerticalPosition.Margin,
100, 200, 100, aw.Drawing.WrapType.Square);
doc.save(base.artifactsDir + "DocumentBuilder.InsertedChartRelativePosition.docx");
See Also
- module Aspose.Words
- class DocumentBuilder