Excel.ChartDataLabels class

Represents a collection of all the data labels on a chart point.

[ API set: ExcelApi 1.1 ]

Extends
OfficeExtension.ClientObject

Properties

format

Represents the format of chart data labels, which includes fill and font formatting. Read-only.

[ API set: ExcelApi 1.1 ]

position

DataLabelPosition value that represents the position of the data label. See Excel.ChartDataLabelPosition for details.

[ API set: ExcelApi 1.1 ]

separator

String representing the separator used for the data labels on a chart.

[ API set: ExcelApi 1.1 ]

showBubbleSize

Boolean value representing if the data label bubble size is visible or not.

[ API set: ExcelApi 1.1 ]

showCategoryName

Boolean value representing if the data label category name is visible or not.

[ API set: ExcelApi 1.1 ]

showLegendKey

Boolean value representing if the data label legend key is visible or not.

[ API set: ExcelApi 1.1 ]

showPercentage

Boolean value representing if the data label percentage is visible or not.

[ API set: ExcelApi 1.1 ]

showSeriesName

Boolean value representing if the data label series name is visible or not.

[ API set: ExcelApi 1.1 ]

showValue

Boolean value representing if the data label value is visible or not.

[ API set: ExcelApi 1.1 ]

Methods

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

toJSON()

Property Details

format

Represents the format of chart data labels, which includes fill and font formatting. Read-only.

[ API set: ExcelApi 1.1 ]

readonly format: Excel.ChartDataLabelFormat;
Property Value

position

DataLabelPosition value that represents the position of the data label. See Excel.ChartDataLabelPosition for details.

[ API set: ExcelApi 1.1 ]

position: Excel.ChartDataLabelPosition | "Invalid" | "None" | "Center" | "InsideEnd" | "InsideBase" | "OutsideEnd" | "Left" | "Right" | "Top" | "Bottom" | "BestFit" | "Callout";
Property Value
Excel.ChartDataLabelPosition | "Invalid" | "None" | "Center" | "InsideEnd" | "InsideBase" | "OutsideEnd" | "Left" | "Right" | "Top" | "Bottom" | "BestFit" | "Callout"

separator

String representing the separator used for the data labels on a chart.

[ API set: ExcelApi 1.1 ]

separator: string;
Property Value
string

showBubbleSize

Boolean value representing if the data label bubble size is visible or not.

[ API set: ExcelApi 1.1 ]

showBubbleSize: boolean;
Property Value
boolean

showCategoryName

Boolean value representing if the data label category name is visible or not.

[ API set: ExcelApi 1.1 ]

showCategoryName: boolean;
Property Value
boolean

showLegendKey

Boolean value representing if the data label legend key is visible or not.

[ API set: ExcelApi 1.1 ]

showLegendKey: boolean;
Property Value
boolean

showPercentage

Boolean value representing if the data label percentage is visible or not.

[ API set: ExcelApi 1.1 ]

showPercentage: boolean;
Property Value
boolean

showSeriesName

Boolean value representing if the data label series name is visible or not.

[ API set: ExcelApi 1.1 ]

showSeriesName: boolean;
Property Value
boolean

showValue

Boolean value representing if the data label value is visible or not.

[ API set: ExcelApi 1.1 ]

showValue: boolean;
Property Value
boolean

Method Details

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

load(option?: string | string[]): Excel.ChartDataLabels;
Parameters
option
string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns
Remarks

In addition to this signature, this method has the following signatures:

load(option?: { select?: string; expand?: string; }): Excel.ChartDataLabels - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.ChartDataLabels - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items.

Examples

// Make Series Name shown in Datalabels and set the position of datalabels to be "top";
Excel.run(function (ctx) { 
    var chart = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1");    
    chart.datalabels.showValue = true;
    chart.datalabels.position = "top";
    chart.datalabels.showSeriesName = true;
    return ctx.sync().then(function() {
            console.log("Datalabels Shown");
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

toJSON()

toJSON(): Excel.Interfaces.ChartDataLabelsData;
Returns