Aspose::Words::DocumentBuilder::InsertChart method

DocumentBuilder::InsertChart(Aspose::Words::Drawing::Charts::ChartType, Aspose::Words::Drawing::RelativeHorizontalPosition, double, Aspose::Words::Drawing::RelativeVerticalPosition, double, double, double, Aspose::Words::Drawing::WrapType) method

Inserts an chart object into the document and scales it to the specified size.

System::SharedPtr<Aspose::Words::Drawing::Shape> Aspose::Words::DocumentBuilder::InsertChart(Aspose::Words::Drawing::Charts::ChartType chartType, Aspose::Words::Drawing::RelativeHorizontalPosition horzPos, double left, Aspose::Words::Drawing::RelativeVerticalPosition vertPos, double top, double width, double height, Aspose::Words::Drawing::WrapType wrapType)
ParameterTypeDescription
chartTypeAspose::Words::Drawing::Charts::ChartTypeThe chart type to insert into the document.
horzPosAspose::Words::Drawing::RelativeHorizontalPositionSpecifies where the distance to the image is measured from.
leftdoubleDistance in points from the origin to the left side of the image.
vertPosAspose::Words::Drawing::RelativeVerticalPositionSpecifies where the distance to the image measured from.
topdoubleDistance in points from the origin to the top side of the image.
widthdoubleThe width of the image in points. Can be a negative or zero value to request 100% scale.
heightdoubleThe height of the image in points. Can be a negative or zero value to request 100% scale.
wrapTypeAspose::Words::Drawing::WrapTypeSpecifies how to wrap text around the image.

ReturnValue

The image node that was just inserted.

Remarks

You can change the image size, location, positioning method and other settings using the Shape object returned by this method.

Examples

Shows how to specify position and wrapping while inserting a chart.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

builder->InsertChart(ChartType::Pie, RelativeHorizontalPosition::Margin, 100, RelativeVerticalPosition::Margin, 100, 200, 100, WrapType::Square);

doc->Save(ArtifactsDir + u"DocumentBuilder.InsertedChartRelativePosition.docx");

See Also

DocumentBuilder::InsertChart(Aspose::Words::Drawing::Charts::ChartType, double, double) method

Inserts an chart object into the document and scales it to the specified size.

System::SharedPtr<Aspose::Words::Drawing::Shape> Aspose::Words::DocumentBuilder::InsertChart(Aspose::Words::Drawing::Charts::ChartType chartType, double width, double height)
ParameterTypeDescription
chartTypeAspose::Words::Drawing::Charts::ChartTypeThe chart type to insert into the document.
widthdoubleThe width of the image in points. Can be a negative or zero value to request 100% scale.
heightdoubleThe height of the image in points. Can be a negative or zero value to request 100% scale.

ReturnValue

The image node that was just inserted.

Remarks

You can change the image size, location, positioning method and other settings using the Shape object returned by this method.

Examples

Shows how to insert a pie chart into a document.

auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);

SharedPtr<Chart> chart = builder->InsertChart(ChartType::Pie, ConvertUtil::PixelToPoint(300), ConvertUtil::PixelToPoint(300))->get_Chart();
chart->get_Series()->Clear();
chart->get_Series()->Add(u"My fruit", MakeArray<String>({u"Apples", u"Bananas", u"Cherries"}), MakeArray<double>({1.3, 2.2, 1.5}));

doc->Save(ArtifactsDir + u"DocumentBuilder.InsertPieChart.docx");

See Also