Aspose::Words::Drawing::Charts::ChartLegend class
Contents
[
Hide
]ChartLegend class
Represents chart legend properties. To learn more, visit the Working with Charts documentation article.
class ChartLegend : public Aspose::Words::Drawing::Core::Dml::IDmlExtensionListSource,
public Aspose::Words::Drawing::Charts::Core::IChartFormatSource
Methods
Method | Description |
---|---|
get_Font() | Provides access to the default font formatting of legend entries. To override the font formatting for a specific legend entry, use theFont property. |
get_Format() | Provides access to fill and line formatting of the legend. |
get_LegendEntries() const | Returns a collection of legend entries for all series and trendlines of the parent chart. |
get_Overlay() const | Determines whether other chart elements shall be allowed to overlap legend. Default value is false. |
get_Position() | Specifies the position of the legend on a chart. |
GetType() const override | |
Is(const System::TypeInfo&) const override | |
set_Overlay(bool) | Setter for Aspose::Words::Drawing::Charts::ChartLegend::get_Overlay. |
set_Position(Aspose::Words::Drawing::Charts::LegendPosition) | Setter for Aspose::Words::Drawing::Charts::ChartLegend::get_Position. |
static Type() |
Examples
Shows how to edit the appearance of a chart’s legend.
auto doc = MakeObject<Document>();
auto builder = MakeObject<DocumentBuilder>(doc);
SharedPtr<Shape> shape = builder->InsertChart(ChartType::Line, 450, 300);
SharedPtr<Chart> chart = shape->get_Chart();
ASSERT_EQ(3, chart->get_Series()->get_Count());
ASSERT_EQ(u"Series 1", chart->get_Series()->idx_get(0)->get_Name());
ASSERT_EQ(u"Series 2", chart->get_Series()->idx_get(1)->get_Name());
ASSERT_EQ(u"Series 3", chart->get_Series()->idx_get(2)->get_Name());
// Move the chart's legend to the top right corner.
SharedPtr<ChartLegend> legend = chart->get_Legend();
legend->set_Position(LegendPosition::TopRight);
// Give other chart elements, such as the graph, more room by allowing them to overlap the legend.
legend->set_Overlay(true);
doc->Save(ArtifactsDir + u"Charts.ChartLegend.docx");
See Also
- Namespace Aspose::Words::Drawing::Charts
- Library Aspose.Words for C++