Excel.ChartFill class
Represents the fill formatting for a chart element.
- Extends
Remarks
Properties
context | The request context associated with the object. This connects the add-in's process to the Office host application's process. |
Methods
clear() | Clears the fill color of a chart element. |
get |
Gets the uniform color fill formatting of a chart element. |
set |
Sets the fill formatting of a chart element to a uniform color. |
toJSON() | Overrides the JavaScript |
Property Details
context
The request context associated with the object. This connects the add-in's process to the Office host application's process.
context: RequestContext;
Property Value
Method Details
clear()
Clears the fill color of a chart element.
clear(): void;
Returns
void
Remarks
Examples
// Clear the line format of the major gridlines on the value axis of the chart named "Chart1".
await Excel.run(async (context) => {
const gridlines = context.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1").axes.valueAxis.majorGridlines;
gridlines.format.line.clear();
await context.sync();
console.log("Chart Major Gridlines Format Cleared");
});
getSolidColor()
Gets the uniform color fill formatting of a chart element.
getSolidColor(): OfficeExtension.ClientResult<string>;
Returns
OfficeExtension.ClientResult<string>
Remarks
setSolidColor(color)
Sets the fill formatting of a chart element to a uniform color.
setSolidColor(color: string): void;
Parameters
- color
-
string
HTML color code representing the color of the background, in the form #RRGGBB (e.g., "FFA500") or as a named HTML color (e.g., "orange").
Returns
void
Remarks
Examples
// Link to full sample: https://raw.githubusercontent.com/OfficeDev/office-js-snippets/prod/samples/excel/10-chart/chart-point.yaml
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();
});
toJSON()
Overrides the JavaScript toJSON()
method in order to provide more useful output when an API object is passed to JSON.stringify()
. (JSON.stringify
, in turn, calls the toJSON
method of the object that is passed to it.) Whereas the original Excel.ChartFill
object is an API object, the toJSON
method returns a plain JavaScript object (typed as Excel.Interfaces.ChartFillData
) that contains shallow copies of any loaded child properties from the original object.
toJSON(): {
[key: string]: string;
};
Returns
{ [key: string]: string; }
Office Add-ins