图表图例
Contents
[
Hide
]
图例位置
为了设置图例属性。请按照以下步骤操作:
- 创建 Presentation 类的实例。
- 获取幻灯片的引用。
- 在幻灯片上添加图表。
- 设置图例的属性。
- 将演示文稿写入 PPTX 文件。
在下面给出的示例中,我们为图表图例设置了位置和大小。
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
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 类。
- 创建默认图表。
- 设置字体大小。
- 设置最小轴值。
- 设置最大轴值。
- 将演示文稿写入磁盘。
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
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 类。
- 创建默认图表。
- 访问图例条目。
- 设置字体大小。
- 设置最小轴值。
- 设置最大轴值。
- 将演示文稿写入磁盘。
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
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); | |