Class Legend
Namespace: Aspose.Cells.Charts
Assembly: Aspose.Cells.dll (25.2.0)
Encapsula o objeto que representa a legenda do gráfico.
public class Legend : ChartTextFrame
Herança
object ← ChartFrame ← ChartTextFrame ← Legend
Membros Herdados
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()
Exemplos
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets[0];
Cells cells = sheet.Cells;
cells[0,1].PutValue("Renda");
cells[1,0].PutValue("Empresa A");
cells[2,0].PutValue("Empresa B");
cells[3,0].PutValue("Empresa 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);
//Definir largura e altura da legenda
Legend legend = chart.Legend;
//A legenda está do lado direito do gráfico por padrão.
//Se a legenda estiver do lado esquerdo ou direito do gráfico, definir a propriedade Legend.X não terá efeito.
//Se a legenda estiver na parte superior ou inferior do gráfico, definir a propriedade Legend.Y não terá efeito.
legend.Y = 1500;
legend.Width = 50;
legend.Height = 50;
//Definir a posição da legenda
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("Renda")
cells(1,0).PutValue("Empresa A")
cells(2,0).PutValue("Empresa B")
cells(3,0).PutValue("Empresa 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);
'Definir largura e altura da legenda
Dim legend as Legend = chart.Legend
'A legenda está do lado direito do gráfico por padrão.
'Se a legenda estiver do lado esquerdo ou direito do gráfico, definir a propriedade Legend.X não terá efeito.
'Se a legenda estiver na parte superior ou inferior do gráfico, definir a propriedade Legend.Y não terá efeito.
legend.Y = 1500
legend.Width = 50
legend.Height = 50
'Definir a posição da legenda
legend.Position = LegendPositionType.Left
Propriedades
IsOverLay
Obtém ou define se a legenda é exibida sem sobrepor o gráfico.
public bool IsOverLay { get; set; }
Valor da Propriedade
LegendEntries
Obtém uma coleção de todos os objetos LegendEntry na legenda do gráfico especificado. Definir as entradas da legenda do gráfico de superfície não é suportado. Portanto, retornará nulo se o tipo de gráfico for do tipo gráfico de superfície.
public LegendEntryCollection LegendEntries { get; }
Valor da Propriedade
Position
Obtém ou define o tipo de posição da legenda.
public LegendPositionType Position { get; set; }
Valor da Propriedade
Observações
A posição padrão é à direita.
Se a legenda estiver do lado esquerdo ou direito do gráfico, definir a propriedade Legend.X não terá efeito.
Se a legenda estiver na parte superior ou inferior do gráfico, definir a propriedade Legend.Y não terá efeito.
Métodos
GetLegendLabels()
Obtém os rótulos das entradas da legenda após chamar o método Chart.Calculate().
public string[] GetLegendLabels()
Retorna
string[]