Class Legend
Contents
[
Hide
]Legend class
Encapsulates the object that represents the chart legend.
public class Legend : ChartTextFrame
Properties
Name | Description |
---|---|
virtual Area { get; } | Gets the area .(Inherited from ChartFrame .) |
virtual AutoScaleFont { get; set; } | True if the text in the object changes font size when the object size changes. The default value is True.(Inherited from ChartFrame .) |
Background { get; set; } | (Obsolete.) Gets and sets the display mode of the background(Inherited from ChartFrame .) |
BackgroundMode { get; set; } | Gets and sets the display mode of the background(Inherited from ChartFrame .) |
virtual Border { get; } | Gets the border .(Inherited from ChartFrame .) |
DefaultHeight { get; } | (Obsolete.) Represents height of default position in units of 1/4000 of the chart area.(Inherited from ChartFrame .) |
DefaultHeightRatioToChart { get; } | Represents height of default position in units of Fraction of the chart area.(Inherited from ChartFrame .) |
DefaultWidth { get; } | (Obsolete.) Represents width of default position in units of 1/4000 of the chart area.(Inherited from ChartFrame .) |
DefaultWidthRatioToChart { get; } | Represents width of default position in units of Fraction of the chart area.(Inherited from ChartFrame .) |
DefaultX { get; } | (Obsolete.) Represents x of default position in units of 1/4000 of the chart area.(Inherited from ChartFrame .) |
DefaultXRatioToChart { get; } | Represents x of default position in units of Fraction of the chart area.(Inherited from ChartFrame .) |
DefaultY { get; } | (Obsolete.) Represents y of default position in units of 1/4000 of the chart area.(Inherited from ChartFrame .) |
DefaultYRatioToChart { get; } | Represents y of default position in units of Fraction of the chart area.(Inherited from ChartFrame .) |
virtual DirectionType { get; set; } | Gets and sets the direction of text.(Inherited from ChartTextFrame .) |
virtual Font { get; } | Gets a Font object of the specified ChartFrame object.(Inherited from ChartFrame .) |
virtual Height { get; set; } | (Obsolete.) Gets or sets the height of frame in units of 1/4000 of the chart area.(Inherited from ChartFrame .) |
virtual HeightPixel { get; set; } | Gets or sets the height of frame in units of Pixel.(Inherited from ChartFrame .) |
virtual HeightRatioToChart { get; set; } | Gets or sets the height of frame in units of ratio of the chart area.(Inherited from ChartFrame .) |
IsAutomaticRotation { get; } | Indicates whether the text of the chart is automatically rotated.(Inherited from ChartTextFrame .) |
virtual IsAutomaticSize { get; set; } | Indicates whether the chart frame is automatic sized.(Inherited from ChartFrame .) |
virtual IsAutoText { get; set; } | Indicates the text is auto generated.(Inherited from ChartTextFrame .) |
IsDefaultPosBeSet { get; } | Indicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set.(Inherited from ChartFrame .) |
IsDeleted { get; set; } | Indicates whether this data labels is deleted.(Inherited from ChartTextFrame .) |
IsInnerMode { get; set; } | Indicates whether the size of the plot area size includes the tick marks, and the axis labels. False specifies that the size shall determine the size of the plot area, the tick marks, and the axis labels.(Inherited from ChartFrame .) |
IsOverLay { get; set; } | Gets or sets whether showing the legend without overlapping the chart. |
IsResizeShapeToFitText { get; set; } | Gets or sets whether a shape should be auto-fit to fully contain the text described within it. Auto-fitting is when text within a shape is scaled in order to contain all the text inside.(Inherited from ChartTextFrame .) |
virtual IsTextWrapped { get; set; } | Gets or sets a value indicating whether the text is wrapped.(Inherited from ChartTextFrame .) |
LegendEntries { get; } | Gets a collection of all the LegendEntry objects in the specified chart legend. Setting the legend entries of the surface chart is not supported. So it will return null if the chart type is surface chart type. |
LegendEntriesLabels { get; } | (Obsolete.) Gets the labels of the legend entries after call Chart.Calculate() method. |
virtual LinkedSource { get; set; } | Gets and sets a reference to the worksheet.(Inherited from ChartTextFrame .) |
Position { get; set; } | Gets or sets the legend position type. |
ReadingOrder { get; set; } | Represents text reading order.(Inherited from ChartTextFrame .) |
RotationAngle { get; set; } | Represents text rotation angle.(Inherited from ChartTextFrame .) |
Shadow { get; set; } | True if the frame has a shadow.(Inherited from ChartFrame .) |
ShapeProperties { get; } | Gets the ShapeProperties object.(Inherited from ChartFrame .) |
virtual Text { get; set; } | Gets or sets the text of a frame’s title.(Inherited from ChartTextFrame .) |
TextDirection { get; set; } | (Obsolete.) Represents text reading order.(Inherited from ChartTextFrame .) |
virtual TextFont { get; } | (Obsolete.) Gets a Font object of the specified ChartFrame object.(Inherited from ChartFrame .) |
TextHorizontalAlignment { get; set; } | Gets and sets the text horizontal alignment.(Inherited from ChartTextFrame .) |
virtual TextOptions { get; } | Gets and sets the options of the text.(Inherited from ChartFrame .) |
TextVerticalAlignment { get; set; } | Gets or sets the text vertical alignment of text.(Inherited from ChartTextFrame .) |
virtual Width { get; set; } | (Obsolete.) Gets or sets the width of frame in units of 1/4000 of the chart area.(Inherited from ChartFrame .) |
virtual WidthPixel { get; set; } | Gets or sets the width of frame in units of Pixel.(Inherited from ChartFrame .) |
virtual WidthRatioToChart { get; set; } | Gets or sets the width of frame in units of ratio of the chart area.(Inherited from ChartFrame .) |
virtual X { get; set; } | (Obsolete.) Gets or sets the x coordinate of the upper left corner in units of 1/4000 of the chart area.(Inherited from ChartFrame .) |
virtual XPixel { get; set; } | Gets or sets the x coordinate of the upper left corner in units of Pixel.(Inherited from ChartFrame .) |
virtual XRatioToChart { get; set; } | Gets or sets the x coordinate of the upper left corner in units of ratio of the chart area.(Inherited from ChartFrame .) |
virtual Y { get; set; } | (Obsolete.) Gets or sets the y coordinate of the upper left corner in units of 1/4000 of the chart area.(Inherited from ChartFrame .) |
virtual YPixel { get; set; } | Gets or sets the y coordinate of the upper left corner in units of Pixel.(Inherited from ChartFrame .) |
virtual YRatioToChart { get; set; } | Gets or sets the y coordinate of the upper left corner in units of ratio of the chart area.(Inherited from ChartFrame .) |
Methods
Name | Description |
---|---|
Characters(int, int) | Returns a Characters object that represents a range of characters within the text.(Inherited from ChartTextFrame .) |
GetLegendLabels() | Gets the labels of the legend entries after call Chart.Calculate() method. |
virtual SetPositionAuto() | Set position of the frame to automatic(Inherited from ChartFrame .) |
Examples
namespace AsposeCellsExamples
{
using Aspose.Cells;
using Aspose.Cells.Charts;
using System;
using System.Drawing;
public class LegendDemo
{
public static void LegendExample()
{
// Create a new workbook
Workbook workbook = new Workbook();
// Get the first worksheet
Worksheet sheet = workbook.Worksheets[0];
// Add sample data to the worksheet
Cells cells = sheet.Cells;
cells[0, 1].PutValue("Income");
cells[1, 0].PutValue("Company A");
cells[2, 0].PutValue("Company B");
cells[3, 0].PutValue("Company C");
cells[1, 1].PutValue(10000);
cells[2, 1].PutValue(20000);
cells[3, 1].PutValue(30000);
// Add a chart to the worksheet
int chartIndex = sheet.Charts.Add(ChartType.Column, 9, 9, 21, 15);
Chart chart = sheet.Charts[chartIndex];
chart.SetChartDataRange("A1:B4", true);
// Access the legend of the chart
Legend legend = chart.Legend;
// Set legend properties
legend.Position = LegendPositionType.Left;
legend.Y = 1500;
legend.Width = 50;
legend.Height = 50;
legend.IsOverLay = false;
legend.IsAutoText = true;
legend.IsDeleted = false;
legend.TextHorizontalAlignment = TextAlignmentType.Center;
legend.TextVerticalAlignment = TextAlignmentType.Center;
legend.RotationAngle = 0;
legend.Text = "Legend Text";
legend.LinkedSource = "Sheet1!A1";
legend.TextDirection = TextDirectionType.LeftToRight;
legend.ReadingOrder = TextDirectionType.Context;
legend.DirectionType = ChartTextDirectionType.Horizontal;
legend.IsTextWrapped = true;
legend.IsResizeShapeToFitText = true;
legend.IsInnerMode = false;
legend.AutoScaleFont = true;
legend.BackgroundMode = BackgroundMode.Transparent;
legend.IsAutomaticSize = true;
legend.X = 100;
legend.Y = 100;
legend.Height = 200;
legend.Width = 200;
legend.Shadow = true;
// Save the workbook
workbook.Save("LegendExample.xlsx");
workbook.Save("LegendExample.pdf");
}
}
}
See Also
- class ChartTextFrame
- namespace Aspose.Cells.Charts
- assembly Aspose.Cells