チャートの凡例

凡例の配置

凡例のプロパティを設定するために、以下の手順に従ってください:

  • Presentation クラスのインスタンスを作成します。
  • スライドの参照を取得します。
  • スライドにチャートを追加します。
  • 凡例のプロパティを設定します。
  • プレゼンテーションを PPTX ファイルとして保存します。

以下の例では、チャートの凡例の位置とサイズを設定しました。

For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String outPath = L"../out/legendCustomOptions_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
// Set Legend Properties
chart->get_Legend()->set_X ( 50 / chart->get_Width());
chart->get_Legend()->set_Y ( 50 / chart->get_Height());
chart->get_Legend()->set_Width ( 100 / chart->get_Width());
chart->get_Legend()->set_Height ( 100 / chart->get_Height());
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

凡例のフォントサイズを設定

Aspose.Slides for C++ では、開発者が凡例のフォントサイズを設定できるようにします。以下の手順に従ってください:

  • Presentation クラスのインスタンスを作成します。
  • デフォルトのチャートを作成します。
  • フォントサイズを設定します。
  • 最小軸値を設定します。
  • 最大軸値を設定します。
  • プレゼンテーションをディスクに書き込みます。
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String outPath = u"../out/SettingFontSizeOfLegend_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
//Setting legend properties
chart->get_Legend()->get_TextFormat()->get_PortionFormat()->set_FontHeight (20);
chart->get_Axes()->get_VerticalAxis()->set_IsAutomaticMinValue (false);
chart->get_Axes()->get_VerticalAxis()->set_MinValue (-5);
chart->get_Axes()->get_VerticalAxis()->set_IsAutomaticMaxValue (false);
chart->get_Axes()->get_VerticalAxis()->set_MaxValue ( 10);
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);

個々の凡例のフォントサイズを設定

Aspose.Slides for C++ では、開発者が個々の凡例エントリのフォントサイズを設定できるようにします。以下の手順に従ってください:

  • Presentation クラスのインスタンスを作成します。
  • デフォルトのチャートを作成します。
  • 凡例エントリにアクセスします。
  • フォントサイズを設定します。
  • 最小軸値を設定します。
  • 最大軸値を設定します。
  • プレゼンテーションをディスクに書き込みます。
For complete examples and data files, please go to https://github.com/aspose-slides/Aspose.Slides-for-C
// The path to the documents directory.
const String outPath = u"../out/SettingFontSizeOfIndividualLegend_out.pptx";
//Instantiate Presentation class that represents PPTX file
SharedPtr<Presentation> pres = MakeObject<Presentation>();
//Access first slide
SharedPtr<ISlide> slide = pres->get_Slides()->idx_get(0);
// Add chart with default data
SharedPtr<IChart> chart = slide->get_Shapes()->AddChart(Aspose::Slides::Charts::ChartType::ClusteredColumn, 0, 0, 500, 500);
//Setting legend properties
SharedPtr<IChartTextFormat> tf = chart->get_Legend()->get_Entries()->idx_get(1)->get_TextFormat();
tf->get_PortionFormat()->set_FontBold (NullableBool::True);
tf->get_PortionFormat()->set_FontHeight(20);
tf->get_PortionFormat()->set_FontItalic(NullableBool::True);
tf->get_PortionFormat()->get_FillFormat()->set_FillType(FillType::Solid) ;
tf->get_PortionFormat()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue());
// Write the presentation file to disk
pres->Save(outPath, Aspose::Slides::Export::SaveFormat::Pptx);