Legend
Legend class
Encapsulates the object that represents the chart legend.
class Legend extends ChartTextFrame;
Example
const { Workbook, ChartType, LegendPositionType } = require("aspose.cells.node");
//Set Legend's width and height
var workbook = new Workbook();
var sheetIndex = workbook.getWorksheets().add();
var worksheet = workbook.getWorksheets().get(sheetIndex);
var charts = worksheet.getCharts();
//Create a chart
var chart = charts.get(charts.add(ChartType.Column, 1, 1, 10, 10));
var legend = chart.getLegend();
//Legend is at right side of chart by default.
//If the legend is at left or right side of the chart, setting Legend.X property will not take effect.
//If the legend is at top or bottom side of the chart, setting Legend.Y property will not take effect.
legend.setY(1500);
legend.setWidth(50);
legend.setHeight(50);
//Set legend's position
legend.setPosition(LegendPositionType.Left);
Constructors
Name | Description |
---|---|
constructor(ChartTextFrame) | Constructs from a parent object convertible to this. |
Methods
Method | Description |
---|---|
getPosition() | Gets or sets the legend position type. |
setPosition(LegendPositionType) | Gets or sets the legend position type. |
getLegendEntries() | 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. |
isOverLay() | Gets or sets whether showing the legend without overlapping the chart. |
setIsOverLay(boolean) | Gets or sets whether showing the legend without overlapping the chart. |
getLegendLabels() | Gets the labels of the legend entries after call Chart.Calculate() method. |
isNull() | Checks whether the implementation object is null. |
isInnerMode() | 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. |
setIsInnerMode(boolean) | 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. |
getBackgroundMode() | Gets and sets the display mode of the background |
setBackgroundMode(BackgroundMode) | Gets and sets the display mode of the background |
getShadow() | True if the frame has a shadow. |
setShadow(boolean) | True if the frame has a shadow. |
getShapeProperties() | Gets the ShapeProperties object. |
isDefaultPosBeSet() | Indicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set. |
getDefaultX() | Represents x of default position |
getDefaultY() | Represents y of default position |
getDefaultWidth() | Represents width of default position |
getDefaultHeight() | Represents height of default position |
setPositionAuto() | Set position of the frame to automatic |
isDeleted() | Indicates whether this data labels is deleted. |
setIsDeleted(boolean) | Indicates whether this data labels is deleted. |
getTextHorizontalAlignment() | Gets and sets the text horizontal alignment. |
setTextHorizontalAlignment(TextAlignmentType) | Gets and sets the text horizontal alignment. |
getTextVerticalAlignment() | Gets or sets the text vertical alignment of text. |
setTextVerticalAlignment(TextAlignmentType) | Gets or sets the text vertical alignment of text. |
getRotationAngle() | Represents text rotation angle. |
setRotationAngle(number) | Represents text rotation angle. |
isAutomaticRotation() | Indicates whether the text of the chart is automatically rotated. |
getReadingOrder() | Represents text reading order. |
setReadingOrder(TextDirectionType) | Represents text reading order. |
isResizeShapeToFitText() | 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. |
setIsResizeShapeToFitText(boolean) | 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. |
characters(number, number) | Returns a Characters object that represents a range of characters within the text. |
getBorder() | Gets the |
getArea() | Gets the |
getTextOptions() | Gets and sets the options of the text. |
getFont() | Gets a Font object of the specified ChartFrame object. |
getAutoScaleFont() | True if the text in the object changes font size when the object size changes. The default value is True. |
setAutoScaleFont(boolean) | True if the text in the object changes font size when the object size changes. The default value is True. |
isAutomaticSize() | Indicates whether the chart frame is automatic sized. |
setIsAutomaticSize(boolean) | Indicates whether the chart frame is automatic sized. |
getX() | Gets or sets the x coordinate of the upper left corner in units of 1/4000 of the chart area. |
setX(number) | Gets or sets the x coordinate of the upper left corner in units of 1/4000 of the chart area. |
getY() | Gets or sets the y coordinate of the upper left corner in units of 1/4000 of the chart area. |
setY(number) | Gets or sets the y coordinate of the upper left corner in units of 1/4000 of the chart area. |
getHeight() | Gets or sets the height of frame in units of 1/4000 of the chart area. |
setHeight(number) | Gets or sets the height of frame in units of 1/4000 of the chart area. |
getWidth() | Gets or sets the width of frame in units of 1/4000 of the chart area. |
setWidth(number) | Gets or sets the width of frame in units of 1/4000 of the chart area. |
isAutoText() | Indicates the text is auto generated. |
setIsAutoText(boolean) | Indicates the text is auto generated. |
getText() | Gets or sets the text of a frame’s title. |
setText(string) | Gets or sets the text of a frame’s title. |
getLinkedSource() | Gets and sets a reference to the worksheet. |
setLinkedSource(string) | Gets and sets a reference to the worksheet. |
getDirectionType() | Gets and sets the direction of text. |
setDirectionType(ChartTextDirectionType) | Gets and sets the direction of text. |
isTextWrapped() | Gets or sets a value indicating whether the text is wrapped. |
setIsTextWrapped(boolean) | Gets or sets a value indicating whether the text is wrapped. |
constructor(ChartTextFrame)
Constructs from a parent object convertible to this.
constructor(obj: ChartTextFrame);
Parameters:
Parameter | Type | Description |
---|---|---|
obj | ChartTextFrame | The parent object. |
getPosition()
Gets or sets the legend position type.
getPosition() : LegendPositionType;
Returns
Remarks
br>Default position is right.
If the legend is at left or right side of the chart, setting Legend.X property will not take effect.
If the legend is at top or bottom side of the chart, setting Legend.Y property will not take effect.</br
setPosition(LegendPositionType)
Gets or sets the legend position type.
setPosition(value: LegendPositionType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | LegendPositionType | The value to set. |
Remarks
br>Default position is right.
If the legend is at left or right side of the chart, setting Legend.X property will not take effect.
If the legend is at top or bottom side of the chart, setting Legend.Y property will not take effect.</br
getLegendEntries()
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.
getLegendEntries() : LegendEntryCollection;
Returns
isOverLay()
Gets or sets whether showing the legend without overlapping the chart.
isOverLay() : boolean;
setIsOverLay(boolean)
Gets or sets whether showing the legend without overlapping the chart.
setIsOverLay(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getLegendLabels()
Gets the labels of the legend entries after call Chart.Calculate() method.
getLegendLabels() : string[];
Returns
string[]
isNull()
Checks whether the implementation object is null.
isNull() : boolean;
isInnerMode()
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.
isInnerMode() : boolean;
Remarks
Only for Xlsx file.
setIsInnerMode(boolean)
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.
setIsInnerMode(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
Remarks
Only for Xlsx file.
getBackgroundMode()
Gets and sets the display mode of the background
getBackgroundMode() : BackgroundMode;
Returns
setBackgroundMode(BackgroundMode)
Gets and sets the display mode of the background
setBackgroundMode(value: BackgroundMode) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | BackgroundMode | The value to set. |
getShadow()
True if the frame has a shadow.
getShadow() : boolean;
setShadow(boolean)
True if the frame has a shadow.
setShadow(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getShapeProperties()
Gets the ShapeProperties object.
getShapeProperties() : ShapePropertyCollection;
Returns
isDefaultPosBeSet()
Indicates whether default position(DefaultX, DefaultY, DefaultWidth and DefaultHeight) are set.
isDefaultPosBeSet() : boolean;
getDefaultX()
Represents x of default position
getDefaultX() : number;
getDefaultY()
Represents y of default position
getDefaultY() : number;
getDefaultWidth()
Represents width of default position
getDefaultWidth() : number;
getDefaultHeight()
Represents height of default position
getDefaultHeight() : number;
setPositionAuto()
Set position of the frame to automatic
setPositionAuto() : void;
isDeleted()
Indicates whether this data labels is deleted.
isDeleted() : boolean;
setIsDeleted(boolean)
Indicates whether this data labels is deleted.
setIsDeleted(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getTextHorizontalAlignment()
Gets and sets the text horizontal alignment.
getTextHorizontalAlignment() : TextAlignmentType;
Returns
setTextHorizontalAlignment(TextAlignmentType)
Gets and sets the text horizontal alignment.
setTextHorizontalAlignment(value: TextAlignmentType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | TextAlignmentType | The value to set. |
getTextVerticalAlignment()
Gets or sets the text vertical alignment of text.
getTextVerticalAlignment() : TextAlignmentType;
Returns
setTextVerticalAlignment(TextAlignmentType)
Gets or sets the text vertical alignment of text.
setTextVerticalAlignment(value: TextAlignmentType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | TextAlignmentType | The value to set. |
getRotationAngle()
Represents text rotation angle.
getRotationAngle() : number;
Remarks
br>0: Not rotated.
255: Top to Bottom.
-90: Downward.
90: Upward.</br
setRotationAngle(number)
Represents text rotation angle.
setRotationAngle(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
br>0: Not rotated.
255: Top to Bottom.
-90: Downward.
90: Upward.</br
isAutomaticRotation()
Indicates whether the text of the chart is automatically rotated.
isAutomaticRotation() : boolean;
getReadingOrder()
Represents text reading order.
getReadingOrder() : TextDirectionType;
Returns
setReadingOrder(TextDirectionType)
Represents text reading order.
setReadingOrder(value: TextDirectionType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | TextDirectionType | The value to set. |
isResizeShapeToFitText()
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.
isResizeShapeToFitText() : boolean;
setIsResizeShapeToFitText(boolean)
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.
setIsResizeShapeToFitText(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
characters(number, number)
Returns a Characters object that represents a range of characters within the text.
characters(startIndex: number, length: number) : FontSetting;
Parameters:
Parameter | Type | Description |
---|---|---|
startIndex | number | The index of the start of the character. |
length | number | The number of characters. |
Returns
Characters object.
getBorder()
Gets the
getBorder() : Line;
Returns
getArea()
Gets the
getArea() : Area;
Returns
getTextOptions()
Gets and sets the options of the text.
getTextOptions() : TextOptions;
Returns
getFont()
Gets a Font object of the specified ChartFrame object.
getFont() : Font;
Returns
getAutoScaleFont()
True if the text in the object changes font size when the object size changes. The default value is True.
getAutoScaleFont() : boolean;
setAutoScaleFont(boolean)
True if the text in the object changes font size when the object size changes. The default value is True.
setAutoScaleFont(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
isAutomaticSize()
Indicates whether the chart frame is automatic sized.
isAutomaticSize() : boolean;
setIsAutomaticSize(boolean)
Indicates whether the chart frame is automatic sized.
setIsAutomaticSize(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getX()
Gets or sets the x coordinate of the upper left corner in units of 1/4000 of the chart area.
getX() : number;
Remarks
How to convert units of 1/4000 to pixels? X In Pixels = X * Chart.ChartObject.Width / 4000;
setX(number)
Gets or sets the x coordinate of the upper left corner in units of 1/4000 of the chart area.
setX(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
How to convert units of 1/4000 to pixels? X In Pixels = X * Chart.ChartObject.Width / 4000;
getY()
Gets or sets the y coordinate of the upper left corner in units of 1/4000 of the chart area.
getY() : number;
Remarks
How to convert units of 1/4000 to pixels? Y In Pixels = Y * Chart.ChartObject.Height / 4000;
setY(number)
Gets or sets the y coordinate of the upper left corner in units of 1/4000 of the chart area.
setY(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
How to convert units of 1/4000 to pixels? Y In Pixels = Y * Chart.ChartObject.Height / 4000;
getHeight()
Gets or sets the height of frame in units of 1/4000 of the chart area.
getHeight() : number;
Remarks
How to convert units of 1/4000 to pixels? Height In Pixels = Y * Chart.ChartObject.Height / 4000;
setHeight(number)
Gets or sets the height of frame in units of 1/4000 of the chart area.
setHeight(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
How to convert units of 1/4000 to pixels? Height In Pixels = Y * Chart.ChartObject.Height / 4000;
getWidth()
Gets or sets the width of frame in units of 1/4000 of the chart area.
getWidth() : number;
Remarks
How to convert units of 1/4000 to pixels? Width In Pixels = Width * Chart.ChartObject.Height / 4000;
setWidth(number)
Gets or sets the width of frame in units of 1/4000 of the chart area.
setWidth(value: number) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | number | The value to set. |
Remarks
How to convert units of 1/4000 to pixels? Width In Pixels = Width * Chart.ChartObject.Height / 4000;
isAutoText()
Indicates the text is auto generated.
isAutoText() : boolean;
setIsAutoText(boolean)
Indicates the text is auto generated.
setIsAutoText(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |
getText()
Gets or sets the text of a frame’s title.
getText() : string;
setText(string)
Gets or sets the text of a frame’s title.
setText(value: string) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | string | The value to set. |
getLinkedSource()
Gets and sets a reference to the worksheet.
getLinkedSource() : string;
setLinkedSource(string)
Gets and sets a reference to the worksheet.
setLinkedSource(value: string) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | string | The value to set. |
getDirectionType()
Gets and sets the direction of text.
getDirectionType() : ChartTextDirectionType;
Returns
setDirectionType(ChartTextDirectionType)
Gets and sets the direction of text.
setDirectionType(value: ChartTextDirectionType) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | ChartTextDirectionType | The value to set. |
isTextWrapped()
Gets or sets a value indicating whether the text is wrapped.
isTextWrapped() : boolean;
setIsTextWrapped(boolean)
Gets or sets a value indicating whether the text is wrapped.
setIsTextWrapped(value: boolean) : void;
Parameters:
Parameter | Type | Description |
---|---|---|
value | boolean | The value to set. |