Aspose::Words::Drawing::Charts::ChartLegend Class Reference

Detailed Description

Represents chart legend properties.

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");

#include <Aspose.Words.Cpp/Drawing/Charts/ChartLegend.h>

+ Inheritance diagram for Aspose::Words::Drawing::Charts::ChartLegend:

Public Member Functions

 ChartLegend ()
 
SharedPtr< ChartLegendEntryCollectionget_LegendEntries () const
 Returns a collection of legend entries for all series and trendlines of the parent chart. More...
 
bool get_Overlay () const
 Determines whether other chart elements shall be allowed to overlap legend. Default value is false. More...
 
LegendPosition get_Position () const
 Specifies the position of the legend on a chart. Default value is Right. More...
 
virtual const TypeInfoGetType () const override
 
virtual bool Is (const TypeInfo &target) const override
 
void set_Overlay (bool value)
 Setter for get_Overlay. More...
 
void set_Position (LegendPosition value)
 Setter for get_Position. More...
 

Static Public Member Functions

static const TypeInfoType ()
 

Constructor & Destructor Documentation

◆ ChartLegend()

Aspose::Words::Drawing::Charts::ChartLegend::ChartLegend ( )

Member Function Documentation

◆ get_LegendEntries()

System::SharedPtr< Aspose::Words::Drawing::Charts::ChartLegendEntryCollection > Aspose::Words::Drawing::Charts::ChartLegend::get_LegendEntries ( ) const

Returns a collection of legend entries for all series and trendlines of the parent chart.

◆ get_Overlay()

bool Aspose::Words::Drawing::Charts::ChartLegend::get_Overlay ( ) const

Determines whether other chart elements shall be allowed to overlap legend. Default value is false.

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");

◆ get_Position()

Aspose::Words::Drawing::Charts::LegendPosition Aspose::Words::Drawing::Charts::ChartLegend::get_Position ( ) const

Specifies the position of the legend on a chart. Default value is Right.

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");

◆ GetType()

virtual const System::TypeInfo & Aspose::Words::Drawing::Charts::ChartLegend::GetType ( ) const
overridevirtual

◆ Is()

virtual bool Aspose::Words::Drawing::Charts::ChartLegend::Is ( const System::TypeInfo target) const
overridevirtual

◆ set_Overlay()

void Aspose::Words::Drawing::Charts::ChartLegend::set_Overlay ( bool  value)

◆ set_Position()

void Aspose::Words::Drawing::Charts::ChartLegend::set_Position ( Aspose::Words::Drawing::Charts::LegendPosition  value)

◆ Type()

static const System::TypeInfo & Aspose::Words::Drawing::Charts::ChartLegend::Type ( )
static