search/mag_sel search/close
Aspose::Words::Drawing::Charts::ChartLegend Class Reference

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< Aspose::Collections::StringToObjDictionary< SharedPtr< Aspose::Words::Drawing::Core::Dml::DmlExtension > > > get_Extensions () override
 
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_Extensions (SharedPtr< Aspose::Collections::StringToObjDictionary< SharedPtr< Aspose::Words::Drawing::Core::Dml::DmlExtension >>> value) 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_Extensions()

System::SharedPtr<Aspose::Collections::StringToObjDictionary<System::SharedPtr<Aspose::Words::Drawing::Core::Dml::DmlExtension> > > Aspose::Words::Drawing::Charts::ChartLegend::get_Extensions ( )
override

◆ 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_Extensions()

void Aspose::Words::Drawing::Charts::ChartLegend::set_Extensions ( System::SharedPtr< Aspose::Collections::StringToObjDictionary< System::SharedPtr< Aspose::Words::Drawing::Core::Dml::DmlExtension >>>  value)
override

◆ 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