ExcelScript.ChartLegend interface
Represents the legend in a chart.
Remarks
Examples
/**
* This sample configures the chart legend.
* This assumes the active worksheet has a chart.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first chart on the active worksheet.
const sheet = workbook.getActiveWorksheet();
const chart = sheet.getCharts()[0];
// Configure the legend.
const legend = chart.getLegend();
legend.setPosition(ExcelScript.ChartLegendPosition.bottom);
legend.setVisible(true);
}
Methods
| get |
Represents the formatting of a chart legend, which includes fill and font formatting. |
| get |
Specifies the height, in points, of the legend on the chart. Value is |
| get |
Specifies the left value, in points, of the legend on the chart. Value is |
| get |
Represents a collection of legendEntries in the legend. |
| get |
Specifies if the chart legend should overlap with the main body of the chart. |
| get |
Specifies the position of the legend on the chart. See |
| get |
Specifies if the legend has a shadow on the chart. |
| get |
Specifies the top of a chart legend. |
| get |
Specifies if the chart legend is visible. |
| get |
Specifies the width, in points, of the legend on the chart. Value is |
| set |
Specifies the height, in points, of the legend on the chart. Value is |
| set |
Specifies the left value, in points, of the legend on the chart. Value is |
| set |
Specifies if the chart legend should overlap with the main body of the chart. |
| set |
Specifies the position of the legend on the chart. See |
| set |
Specifies if the legend has a shadow on the chart. |
| set |
Specifies the top of a chart legend. |
| set |
Specifies if the chart legend is visible. |
| set |
Specifies the width, in points, of the legend on the chart. Value is |
Method Details
getFormat()
Represents the formatting of a chart legend, which includes fill and font formatting.
getFormat(): ChartLegendFormat;
Returns
getHeight()
Specifies the height, in points, of the legend on the chart. Value is null if the legend is not visible.
getHeight(): number;
Returns
number
getLeft()
Specifies the left value, in points, of the legend on the chart. Value is null if the legend is not visible.
getLeft(): number;
Returns
number
getLegendEntries()
Represents a collection of legendEntries in the legend.
getLegendEntries(): ChartLegendEntry[];
Returns
getOverlay()
Specifies if the chart legend should overlap with the main body of the chart.
getOverlay(): boolean;
Returns
boolean
getPosition()
Specifies the position of the legend on the chart. See ExcelScript.ChartLegendPosition for details.
getPosition(): ChartLegendPosition;
Returns
getShowShadow()
Specifies if the legend has a shadow on the chart.
getShowShadow(): boolean;
Returns
boolean
getTop()
Specifies the top of a chart legend.
getTop(): number;
Returns
number
getVisible()
Specifies if the chart legend is visible.
getVisible(): boolean;
Returns
boolean
getWidth()
Specifies the width, in points, of the legend on the chart. Value is null if the legend is not visible.
getWidth(): number;
Returns
number
setHeight(height)
Specifies the height, in points, of the legend on the chart. Value is null if the legend is not visible.
setHeight(height: number): void;
Parameters
- height
-
number
Returns
void
setLeft(left)
Specifies the left value, in points, of the legend on the chart. Value is null if the legend is not visible.
setLeft(left: number): void;
Parameters
- left
-
number
Returns
void
setOverlay(overlay)
Specifies if the chart legend should overlap with the main body of the chart.
setOverlay(overlay: boolean): void;
Parameters
- overlay
-
boolean
Returns
void
setPosition(position)
Specifies the position of the legend on the chart. See ExcelScript.ChartLegendPosition for details.
setPosition(position: ChartLegendPosition): void;
Parameters
- position
- ExcelScript.ChartLegendPosition
Returns
void
Examples
/**
* This sample sets the legend position on a chart.
* This assumes the active worksheet has a chart.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first chart on the active worksheet.
const sheet = workbook.getActiveWorksheet();
const chart = sheet.getCharts()[0];
// Position the legend on the right side.
chart.getLegend().setPosition(ExcelScript.ChartLegendPosition.right);
}
setShowShadow(showShadow)
Specifies if the legend has a shadow on the chart.
setShowShadow(showShadow: boolean): void;
Parameters
- showShadow
-
boolean
Returns
void
setTop(top)
Specifies the top of a chart legend.
setTop(top: number): void;
Parameters
- top
-
number
Returns
void
setVisible(visible)
Specifies if the chart legend is visible.
setVisible(visible: boolean): void;
Parameters
- visible
-
boolean
Returns
void
Examples
/**
* This sample hides the chart legend.
* This assumes the active worksheet has a chart.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the first chart on the active worksheet.
const sheet = workbook.getActiveWorksheet();
const chart = sheet.getCharts()[0];
// Hide the legend.
chart.getLegend().setVisible(false);
}
setWidth(width)
Specifies the width, in points, of the legend on the chart. Value is null if the legend is not visible.
setWidth(width: number): void;
Parameters
- width
-
number
Returns
void