• <menu id="w2i4a"></menu>
  • logo Aspose.Words使用教程

    文檔首頁>>Aspose.Words使用教程>>Aspose.Words for C++使用教程:從Scratch創(chuàng)建OOXML圖表(下)

    Aspose.Words for C++使用教程:從Scratch創(chuàng)建OOXML圖表(下)


    Aspose.Words for C++不依賴Microsoft Word,可在任何C++應(yīng)用程序中生成和操作Word格式文檔。本文將與大家分享如何插入散點(diǎn)圖、面積圖和氣泡圖到文檔中。

    下載Aspose.Words for C++最新試用版

    Aspose.Words for C++提供了 InsertChart 方法,該方法已添加到 DocumentBuilder 類中。那么,讓我們看看如何使用 DocumentBuilder-> InsertChart 方法將簡單的圖表插入到文檔中:

    如何插入散點(diǎn)圖

    下面的示例顯示了如何插入散點(diǎn)圖。

    // The path to the documents directory.
    System::String dataDir = GetDataDir_WorkingWithCharts();
    System::SharedPtr doc = System::MakeObject();
    System::SharedPtr builder = System::MakeObject(doc);
    
    // Insert Scatter chart.
    System::SharedPtr shape = builder->InsertChart(ChartType::Scatter, 432, 252);
    System::SharedPtr chart = shape->get_Chart();
    
    // Use this overload to add series to any type of Scatter charts.
    chart->get_Series()->Add(u"AW Series 1", System::MakeArray({0.7, 1.8, 2.6}), System::MakeArray({2.7, 3.2, 0.8}));
    
    System::String outputPath = dataDir + GetOutputFilePath(u"InsertScatterChart.docx");
    doc->Save(outputPath);
    

    該代碼產(chǎn)生以下結(jié)果:

    ScatterChart

    如何插入面積圖。

    下面的示例顯示了如何插入散點(diǎn)圖。

    // The path to the documents directory.
    System::String dataDir = GetDataDir_WorkingWithCharts();
    System::SharedPtr doc = System::MakeObject();
    System::SharedPtr builder = System::MakeObject(doc);
    
    // Insert Area chart.
    System::SharedPtr shape = builder->InsertChart(ChartType::Area, 432, 252);
    System::SharedPtr chart = shape->get_Chart();
    
    // Use this overload to add series to any type of Area, Radar and Stock charts.
    chart->get_Series()->Add(u"AW Series 1",
                             System::MakeArray({System::DateTime(2002, 5, 1), System::DateTime(2002, 6, 1), System::DateTime(2002, 7, 1), System::DateTime(2002, 8, 1), System::DateTime(2002, 9, 1)}),
                             System::MakeArray({32, 32, 28, 12, 15}));
    System::String outputPath = dataDir + GetOutputFilePath(u"InsertAreaChart.docx");
    doc->Save(outputPath);
    

    該代碼產(chǎn)生以下結(jié)果:

    Area Chart

    如何插入氣泡圖。

    下面的示例顯示了如何插入氣泡圖。

    // The path to the documents directory.
    System::String dataDir = GetDataDir_WorkingWithCharts();
    System::SharedPtr doc = System::MakeObject();
    System::SharedPtr builder = System::MakeObject(doc);
    
    // Insert Bubble chart.
    System::SharedPtr shape = builder->InsertChart(ChartType::Bubble, 432, 252);
    System::SharedPtr chart = shape->get_Chart();
    
    // Use this overload to add series to any type of Bubble charts.
    chart->get_Series()->Add(u"AW Series 1",
                             System::MakeArray({0.7, 1.8, 2.6}),
                             System::MakeArray({2.7, 3.2, 0.8}),
                             System::MakeArray({10, 4, 8}));
    System::String outputPath = dataDir + GetOutputFilePath(u"InsertBubbleChart.docx");
    doc->Save(outputPath);
    

    該代碼產(chǎn)生以下結(jié)果:

    Bubble Chart

    為你推薦:Aspose專題 - Aspose最新資源合集


    想要購買正版授權(quán),或者獲取更多Aspose.Words for C++相關(guān)信息的朋友可以點(diǎn)擊" 咨詢在線客服 "~
    掃碼咨詢


    添加微信 立即咨詢

    電話咨詢

    客服熱線
    023-68661681

    TOP
    三级成人熟女影院,欧美午夜成人精品视频,亚洲国产成人乱色在线观看,色中色成人论坛 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();