การทำงานกับแผนภูมิผ่านShape.Chartวัตถุ

Contents
[ ]

เมื่อแผนภูมิถูกแทรกและเต็มไปด้วยข้อมูลที่คุณสามารถที่จะเปลี่ยนรูปลักษณ์ของมัน Shape.Chartสถานที่ให้บริการประกอบด้วยตัวเลือกทั้งหมดที่เกี่ยวข้องกับแผนภูมิที่มีอยู่ผ่านสาธารณะAPI.

ตัวอย่างเช่นลองเปลี่ยนชื่อแผนภูมิหรือพฤติกรรมตำนาน:

For complete examples and data files, please go to https://github.com/aspose-words/Aspose.Words-for-C
// The path to the documents directory.
System::String outputDataDir = GetOutputDataDir_WorkingWithCharts();
System::SharedPtr<Document> doc = System::MakeObject<Document>();
System::SharedPtr<DocumentBuilder> builder = System::MakeObject<DocumentBuilder>(doc);
System::SharedPtr<Shape> shape = builder->InsertChart(ChartType::Line, 432, 252);
System::SharedPtr<Chart> chart = shape->get_Chart();
// Determines whether the title shall be shown for this chart. Default is true.
chart->get_Title()->set_Show(true);
// Setting chart Title.
chart->get_Title()->set_Text(u"Sample Line Chart Title");
// Determines whether other chart elements shall be allowed to overlap title.
chart->get_Title()->set_Overlay(false);
// Please note if null or empty value is specified as title text, auto generated title will be shown.
// Determines how legend shall be shown for this chart.
chart->get_Legend()->set_Position(LegendPosition::Left);
chart->get_Legend()->set_Overlay(true);
System::String outputPath = outputDataDir + u"CreateChartUsingShape.docx";
doc->Save(outputPath);

รหัสสร้างผลลัพธ์ต่อไปนี้:

line-chart-aspose-words-cpp