Class Legend

Class Legend

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

Zabalí objekt, který představuje legendu grafu.

public class Legend : ChartTextFrame

Dědičnost

objectChartFrameChartTextFrameLegend

Děděné členy

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

Příklady

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

Cells cells = sheet.Cells;
cells[0,1].PutValue("Příjem");
cells[1,0].PutValue("Společnost A");
cells[2,0].PutValue("Společnost B");
cells[3,0].PutValue("Společnost 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);
//Nastavit šířku a výšku legendy
Legend legend = chart.Legend;

//Legenda je ve výchozím nastavení na pravé straně grafu.
//Pokud je legenda na levé nebo pravé straně grafu, nastavení vlastnosti Legend.X nebude mít účinek.
//Pokud je legenda na horní nebo dolní straně grafu, nastavení vlastnosti Legend.Y nebude mít účinek.
legend.Y = 1500;
legend.Width = 50;
legend.Height = 50; 
//Nastavit pozici 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("Příjem")
cells(1,0).PutValue("Společnost A")
cells(2,0).PutValue("Společnost B")
cells(3,0).PutValue("Společnost 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);

'Nastavit šířku a výšku legendy
Dim legend as Legend = chart.Legend

'Legenda je ve výchozím nastavení na pravé straně grafu.
'Pokud je legenda na levé nebo pravé straně grafu, nastavení vlastnosti Legend.X nebude mít účinek.
'Pokud je legenda na horní nebo dolní straně grafu, nastavení vlastnosti Legend.Y nebude mít účinek.
legend.Y = 1500
legend.Width = 50
legend.Height = 50
'Nastavit pozici legendy
legend.Position = LegendPositionType.Left

Vlastnosti

IsOverLay

Získá nebo nastaví, zda se legenda zobrazuje bez překrývání grafu.

public bool IsOverLay { get; set; }

Hodnota vlastnosti

bool

LegendEntries

Získá kolekci všech objektů LegendEntry ve specifikované legendě grafu. Nastavení položek legendy pro povrchový graf není podporováno. Takže vrátí null, pokud je typ grafu typu povrchový graf.

public LegendEntryCollection LegendEntries { get; }

Hodnota vlastnosti

LegendEntryCollection

Position

Získá nebo nastaví typ pozice legendy.

public LegendPositionType Position { get; set; }

Hodnota vlastnosti

LegendPositionType

Poznámky


Výchozí pozice je vpravo.
Pokud je legenda na levé nebo pravé straně grafu, nastavení vlastnosti Legend.X nebude mít účinek.
Pokud je legenda na horní nebo dolní straně grafu, nastavení vlastnosti Legend.Y nebude mít účinek.

Metody

GetLegendLabels()

Získá štítky položek legendy po zavolání metody Chart.Calculate().

public string[] GetLegendLabels()

Vrací

string[]

 Čeština