チャートプロットエリア
Contents
[
Hide
]
チャートプロットエリアの幅と高さを取得する
Aspose.Slides for C++はシンプルなAPIを提供します。
- Presentation クラスのインスタンスを作成します。
- 最初のスライドにアクセスします。
- デフォルトデータを使ってチャートを追加します。
- 実際の値を取得する前に、IChart::ValidateChartLayout() メソッドを呼び出します。
- チャートの左上隅に対するチャート要素の実際のX位置(左)を取得します。
- チャートの左上隅に対するチャート要素の実際の上端を取得します。
- チャート要素の実際の幅を取得します。
- チャート要素の実際の高さを取得します。
auto pres = System::MakeObject<Presentation>(u"test.Pptx");
auto chart = System::ExplicitCast<Chart>(pres->get_Slides()->idx_get(0)->get_Shapes()->AddChart(ChartType::ClusteredColumn, 100.0f, 100.0f, 500.0f, 350.0f));
chart->ValidateChartLayout();
double x = chart->get_PlotArea()->get_ActualX();
double y = chart->get_PlotArea()->get_ActualY();
double w = chart->get_PlotArea()->get_ActualWidth();
double h = chart->get_PlotArea()->get_ActualHeight();
// チャート付きプレゼンテーションを保存
pres->Save(u"Chart_out.pptx", SaveFormat::Pptx);
チャートプロットエリアのレイアウトモードを設定する
Aspose.Slides for C++は、チャートプロットエリアのレイアウトモードを設定するためのシンプルなAPIを提供します。プロパティLayoutTargetTypeはChartPlotAreaおよびIChartPlotAreaクラスに追加されています。プロットエリアのレイアウトが手動で定義されている場合、このプロパティはプロットエリアを内側(軸や軸ラベルを含まない)または外側(軸や軸ラベルを含む)でレイアウトするかどうかを指定します。LayoutTargetType列挙型で定義された2つの可能な値があります。
- LayoutTargetType.Inner - プロットエリアサイズが、目盛りと軸ラベルを含まないプロットエリアのサイズを決定することを指定します。
- LayoutTargetType.Outer - プロットエリアサイズが、目盛りおよび軸ラベルを含むプロットエリアのサイズを決定することを指定します。
サンプルコードは以下の通りです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The path to the documents directory. | |
const String outPath = u"../out/SetLayoutMode_out.pptx"; | |
System::SharedPtr<Presentation> presentation = System::MakeObject<Presentation>(); | |
System::SharedPtr<ISlide> slide = presentation->get_Slides()->idx_get(0); | |
System::SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 20.0f, 100.0f, 600.0f, 400.0f); | |
chart->get_PlotArea()->set_X(0.2f); | |
chart->get_PlotArea()->set_Y(0.2f); | |
chart->get_PlotArea()->set_Width(0.7f); | |
chart->get_PlotArea()->set_Height(0.7f); | |
chart->get_PlotArea()->set_LayoutTargetType(Aspose::Slides::Charts::LayoutTargetType::Inner); | |
presentation->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx); | |