Excel.ChartFill class

Represents the fill formatting for a chart element.

[ API set: ExcelApi 1.1 ]

Extends
OfficeExtension.ClientObject

Methods

clear()

Clear the fill color of a chart element.

[ API set: ExcelApi 1.1 ]

load(option)

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

setSolidColor(color)

Sets the fill formatting of a chart element to a uniform color.

[ API set: ExcelApi 1.1 ]

toJSON()

Method Details

clear()

Clear the fill color of a chart element.

[ API set: ExcelApi 1.1 ]

clear(): void;
Returns
void

Examples

// Clear the line format of the major Gridlines on value axis of the Chart named "Chart1"
Excel.run(function (ctx) { 
    var gridlines = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1").axes.valueAxis.majorGridlines;
    gridlines.format.line.clear();
    return ctx.sync().then(function() {
            console.log("Chart Major Gridlines Format Cleared");
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});

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[] | OfficeExtension.LoadOption): Excel.ChartFill;
Parameters
option
string | string | OfficeExtension.LoadOption[]
Returns

setSolidColor(color)

Sets the fill formatting of a chart element to a uniform color.

[ API set: ExcelApi 1.1 ]

setSolidColor(color: string): void;
Parameters
color
string

HTML color code representing the color of the border line, of the form #RRGGBB (e.g. "FFA500") or as a named HTML color (e.g. "orange").

Returns
void

Examples

Excel.run(function (ctx) { 
    var chart = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1");    

    chart.format.fill.setSolidColor("#FF0000");

    return ctx.sync().then(function() {
            console.log("Chart1 Background Color Changed.");
    });
}).catch(function(error) {
    console.log("Error: " + error);
    if (error instanceof OfficeExtension.Error) {
        console.log("Debug info: " + JSON.stringify(error.debugInfo));
    }
});
await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");

    let pointsCollection = sheet.charts.getItemAt(0).series.getItemAt(0).points;
    let point = pointsCollection.getItemAt(2);

    // Set color for chart point.
    point.format.fill.setSolidColor('red');

    await context.sync();

    OfficeHelpers.UI.notify("Successfully set chart point color to red (for the third item in series 1).");            
});

toJSON()

toJSON:
Returns
{ [key: string]: string; }