Class Legend
Namespace: Aspose.Cells.Charts
Assembly: Aspose.Cells.dll (25.2.0)
Encapsuluje obiekt, który reprezentuje legendę wykresu.
public class Legend : ChartTextFrame
Dziedziczenie
object ← ChartFrame ← ChartTextFrame ← Legend
Członkowie dziedziczeni
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()
Przykłady
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;
cells[0,1].PutValue("Dochód");
cells[1,0].PutValue("Firma A");
cells[2,0].PutValue("Firma B");
cells[3,0].PutValue("Firma 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);
//Ustaw szerokość i wysokość legendy
Legend legend = chart.Legend;
//Legenda jest domyślnie po prawej stronie wykresu.
//Jeśli legenda znajduje się po lewej lub prawej stronie wykresu, ustawienie właściwości Legend.X nie będzie miało efektu.
//Jeśli legenda znajduje się na górze lub na dole wykresu, ustawienie właściwości Legend.Y nie będzie miało efektu.
legend.Y = 1500;
legend.Width = 50;
legend.Height = 50;
//Ustaw pozycję legendy
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("Dochód")
cells(1,0).PutValue("Firma A")
cells(2,0).PutValue("Firma B")
cells(3,0).PutValue("Firma 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);
'Ustaw szerokość i wysokość legendy
Dim legend as Legend = chart.Legend
'Legenda jest domyślnie po prawej stronie wykresu.
'Jeśli legenda znajduje się po lewej lub prawej stronie wykresu, ustawienie właściwości Legend.X nie będzie miało efektu.
'Jeśli legenda znajduje się na górze lub na dole wykresu, ustawienie właściwości Legend.Y nie będzie miało efektu.
legend.Y = 1500
legend.Width = 50
legend.Height = 50
'Ustaw pozycję legendy
legend.Position = LegendPositionType.Left
Właściwości
IsOverLay
Pobiera lub ustawia, czy wyświetlanie legendy bez nakładania się na wykres.
public bool IsOverLay { get; set; }
Wartość właściwości
LegendEntries
Pobiera kolekcję wszystkich obiektów LegendEntry w określonej legendzie wykresu. Ustawienie wpisów legendy dla wykresu powierzchniowego nie jest obsługiwane. Zatem zwróci null, jeśli typ wykresu to typ wykresu powierzchniowego.
public LegendEntryCollection LegendEntries { get; }
Wartość właściwości
Position
Pobiera lub ustawia typ pozycji legendy.
public LegendPositionType Position { get; set; }
Wartość właściwości
Uwagi
Domyślna pozycja to prawo.
Jeśli legenda znajduje się po lewej lub prawej stronie wykresu, ustawienie właściwości Legend.X nie będzie miało efektu.
Jeśli legenda znajduje się na górze lub na dole wykresu, ustawienie właściwości Legend.Y nie będzie miało efektu.
Metody
GetLegendLabels()
Pobiera etykiety wpisów legendy po wywołaniu metody Chart.Calculate().
public string[] GetLegendLabels()
Zwraca
string[]