ChartSeries Object (JavaScript API for Excel)

Represents a series in a chart.

Properties

Property Type Description Req. Set
chartType string Represents the chart type of a series. Possible values are: ColumnClustered, ColumnStacked, ColumnStacked100, BarClustered, BarStacked, BarStacked100, LineStacked, LineStacked100, LineMarkers, LineMarkersStacked, LineMarkersStacked100, PieOfPie, etc.. 1.7
doughnutHoleSize double Represents the doughnut hole size of a chart series. Only valid on doughnut and doughnutExploded charts. 1.7
filtered bool Boolean value representing if the series is filtered or not. Not applicable for surface charts. 1.7
gapWidth double Represents the gap width of a chart series. Only valid on bar and column charts, as well as 1.7
hasDataLabels bool Boolean value representing if the series has data labels or not. 1.7
markerBackgroundColor string Represents markers background color of a chart series. 1.7
markerForegroundColor string Represents markers foreground color of a chart series. 1.7
markerSize int Represents marker size of a chart series. 1.7
markerStyle string Represents marker style of a chart series. Possible values are: Invalid, Automatic, None, Square, Diamond, Triangle, X, Star, Dot, Dash, Circle, Plus, Picture. 1.7
name string Represents the name of a series in a chart. 1.1
plotOrder int Represents the plot order of a chart series within the chart group. 1.7
showShadow bool Boolean value representing if the series has shadow or not. 1.7
smooth bool Boolean value representing if the series is smooth or not. Only for line and scatter charts. 1.7

See property access examples.

Relationships

Relationship Type Description Req. Set
format ChartSeriesFormat Represents the formatting of a chart series, which includes fill and line formatting. Read-only. 1.1
points ChartPointsCollection Represents a collection of all points in the series. Read-only. 1.1
trendlines ChartTrendlineCollection Represents a collection of trendlines in the series. Read-only. 1.7

Methods

Method Return Type Description Req. Set
delete() void Deletes the chart series. 1.7
setBubbleSizes(sourceData: Range) void Set bubble sizes for a chart series. Only works for bubble charts. 1.7
setValues(sourceData: Range) void Set values for a chart series. For scatter chart, it means Y axis values. 1.7
setXAxisValues(sourceData: Range) void Set values of X axis for a chart series. Only works for scatter charts. 1.7

Method Details

delete()

Deletes the chart series.

Syntax

chartSeriesObject.delete();

Parameters

None

Returns

void

setBubbleSizes(sourceData: Range)

Set bubble sizes for a chart series. Only works for bubble charts.

Syntax

chartSeriesObject.setBubbleSizes(sourceData);

Parameters

Parameter Type Description
sourceData Range The Range object corresponding to the source data.

Returns

void

setValues(sourceData: Range)

Set values for a chart series. For scatter chart, it means Y axis values.

Syntax

chartSeriesObject.setValues(sourceData);

Parameters

Parameter Type Description
sourceData Range The Range object corresponding to the source data.

Returns

void

setXAxisValues(sourceData: Range)

Set values of X axis for a chart series. Only works for scatter charts.

Syntax

chartSeriesObject.setXAxisValues(sourceData);

Parameters

Parameter Type Description
sourceData Range The Range object corresponding to the source data.

Returns

void

Property access examples

Rename the 1st series of Chart1 to "New Series Name"

Excel.run(function (ctx) { 
    var chart = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1"); 
    chart.series.getItemAt(0).name = "New Series Name";
    return ctx.sync().then(function() {
            console.log("Series1 Renamed");
    });
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});