ChartLegend Class

Represents chart legend properties.

ExpandedInheritance Hierarchy

SystemObject
  Aspose.Words.Drawing.ChartsChartLegend

Namespace:  Aspose.Words.Drawing.Charts
Assembly:  Aspose.Words (in Aspose.Words.dll) Version: 22.1.0

ExpandedSyntax

public class ChartLegend

The ChartLegend type exposes the following members.

ExpandedConstructors

  NameDescription
Public methodChartLegend
Initializes a new instance of the ChartLegend class

ExpandedProperties

  NameDescription
Public propertyCode exampleOverlay
Determines whether other chart elements shall be allowed to overlap legend. Default value is false.
Public propertyCode examplePosition
Specifies the position of the legend on a chart. Default value is Right.

ExpandedMethods

  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)

ExpandedExamples

Shows how to edit the appearance of a chart's legend.
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

Shape shape = builder.InsertChart(ChartType.Line, 450, 300);
Chart chart = shape.Chart;

Assert.AreEqual(3, chart.Series.Count);
Assert.AreEqual("Series 1", chart.Series[0].Name);
Assert.AreEqual("Series 2", chart.Series[1].Name);
Assert.AreEqual("Series 3", chart.Series[2].Name);

// Move the chart's legend to the top right corner.
ChartLegend legend = chart.Legend;
legend.Position = LegendPosition.TopRight;

// Give other chart elements, such as the graph, more room by allowing them to overlap the legend.
legend.Overlay = true;

doc.Save(ArtifactsDir + "Charts.ChartLegend.docx");

ExpandedSee Also