Class Legend

Class Legend

Namespace: Aspose.Cells.Charts
Assembly: Aspose.Cells.dll (25.2.0)

Encapsule l’objet qui représente la légende du graphique.

public class Legend : ChartTextFrame

Héritage

objectChartFrameChartTextFrameLegend

Membres hérités

ChartTextFrame.m_IsAutoText, ChartTextFrame.m_deleted, ChartTextFrame.horizontal, ChartTextFrame.vertical, ChartTextFrame.rotation, ChartTextFrame.m_CharsList, ChartTextFrame.Characters(int, int), ChartTextFrame.IsAutoText, ChartTextFrame.IsDeleted, ChartTextFrame.TextHorizontalAlignment, ChartTextFrame.TextVerticalAlignment, ChartTextFrame.RotationAngle, ChartTextFrame.IsAutomaticRotation, ChartTextFrame.Text, ChartTextFrame.LinkedSource, ChartTextFrame.ReadingOrder, ChartTextFrame.DirectionType, ChartTextFrame.IsTextWrapped, ChartTextFrame.IsResizeShapeToFitText, ChartFrame.m_IsAutoXPos, ChartFrame.m_IsAutoYPos, ChartFrame.m_IsOffsetPosBeSet, ChartFrame.m_fontIndex, ChartFrame.m_AutoScaleFont, ChartFrame.m_BackgroundMode, ChartFrame.m_isAutoSize, ChartFrame.SetPositionAuto(), ChartFrame.IsInnerMode, ChartFrame.Border, ChartFrame.Area, ChartFrame.TextOptions, ChartFrame.Font, ChartFrame.AutoScaleFont, ChartFrame.BackgroundMode, ChartFrame.IsAutomaticSize, ChartFrame.X, ChartFrame.Y, ChartFrame.Height, ChartFrame.Width, ChartFrame.Shadow, ChartFrame.ShapeProperties, ChartFrame.IsDefaultPosBeSet, ChartFrame.DefaultX, ChartFrame.DefaultY, ChartFrame.DefaultWidth, ChartFrame.DefaultHeight, object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Exemples

Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];

Cells cells = sheet.Cells;
cells[0,1].PutValue("Revenu");
cells[1,0].PutValue("Société A");
cells[2,0].PutValue("Société B");
cells[3,0].PutValue("Société C");
cells[1,1].PutValue(10000);
cells[2,1].PutValue(20000);
cells[3,1].PutValue(30000);

int chartIndex = sheet.Charts.Add(ChartType.Column, 9, 9, 21, 15);
Chart chart = sheet.Charts[chartIndex];
chart.SetChartDataRange("A1:B4", true);
//Définir la largeur et la hauteur de la légende
Legend legend = chart.Legend;

//La légende est par défaut à droite du graphique.
//Si la légende est à gauche ou à droite du graphique, le réglage de la propriété Legend.X n'aura pas d'effet.
//Si la légende est en haut ou en bas du graphique, le réglage de la propriété Legend.Y n'aura pas d'effet.
legend.Y = 1500;
legend.Width = 50;
legend.Height = 50; 
//Définir la position de la légende
legend.Position = LegendPositionType.Left;
Dim workbook as Workbook = new Workbook()
Dim sheet as Worksheet = workbook.Worksheets(0)

Dim cells as Cells = sheet.Cells
cells(0,1).PutValue("Revenu")
cells(1,0).PutValue("Société A")
cells(2,0).PutValue("Société B")
cells(3,0).PutValue("Société C")
cells(1,1).PutValue(10000)
cells(2,1).PutValue(20000)
cells(3,1).PutValue(30000)

Dim chartIndex as Integer = sheet.Charts.Add(ChartType.Column, 9, 9, 21, 15)

Dim chart as Chart = sheet.Charts(chartIndex)
chart.SetChartDataRange("A1:B4", True);

'Définir la largeur et la hauteur de la légende
Dim legend as Legend = chart.Legend

'La légende est par défaut à droite du graphique.
'S'il la légende est à gauche ou à droite du graphique, le réglage de la propriété Legend.X n'aura pas d'effet.
'S'il la légende est en haut ou en bas du graphique, le réglage de la propriété Legend.Y n'aura pas d'effet.
legend.Y = 1500
legend.Width = 50
legend.Height = 50
'Définir la position de la légende
legend.Position = LegendPositionType.Left

Propriétés

IsOverLay

Obtient ou définit si la légende est affichée sans chevauchement du graphique.

public bool IsOverLay { get; set; }

Valeur de propriété

bool

LegendEntries

Obtient une collection de tous les objets LegendEntry dans la légende de graphique spécifiée. La définition des entrées de légende du graphique de surface n’est pas prise en charge. Il renverra donc null si le type de graphique est un graphique de surface.

public LegendEntryCollection LegendEntries { get; }

Valeur de propriété

LegendEntryCollection

Position

Obtient ou définit le type de position de la légende.

public LegendPositionType Position { get; set; }

Valeur de propriété

LegendPositionType

Remarques


La position par défaut est à droite.
Si la légende est à gauche ou à droite du graphique, le réglage de la propriété Legend.X n’aura pas d’effet.
Si la légende est en haut ou en bas du graphique, le réglage de la propriété Legend.Y n’aura pas d’effet.

Méthodes

GetLegendLabels()

Obtient les étiquettes des entrées de légende après avoir appelé la méthode Chart.Calculate().

public string[] GetLegendLabels()

Renvoie

string[]

 Français