Represents the legend in a chart.
Property | Type | Description |
---|---|---|
overlay | bool | Boolean value for whether the chart legend should overlap with the main body of the chart. |
position | string | Represents the position of the legend on the chart. Possible values are: Top, Bottom, Left, Right, Corner, Custom. |
visible | bool | A boolean value the represents the visibility of a ChartLegend object. |
Relationship | Type | Description |
---|---|---|
format | ChartLegendFormat | Represents the formatting of a chart legend, which includes fill and font formatting. Read-only. |
Method | Return Type | Description |
---|---|---|
load(param: object) | void | Fills the proxy object created in JavaScript layer with property and object values specified in the parameter. |
Fills the proxy object created in JavaScript layer with property and object values specified in the parameter.
object.load(param);
Parameter | Type | Description |
---|---|---|
param | object | Optional. Accepts parameter and relationship names as delimited string or an array. Or, provide loadOption object. |
void
Get the position
of Chart Legend from Chart1
var ctx = new Excel.RequestContext();
var chart = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1");
var legend = chart.legend;
ctx.load(legend);
ctx.executeAsync().then(function () {
Console.log(legend.position);
});
Set to show legend of Chart1 and make it on top of the chart.
var ctx = new Excel.RequestContext();
var chart = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1");
chart.legend.visible = true;
chart.legend.position = "top";
chart.legend.overlay = false;
ctx.executeAsync().then(function () {
Console.log("Legend Shown ");
});