ChartTitle Object (JavaScript API for Excel)

Represents a chart title object of a chart.

Properties

Property Type Description Req. Set
overlay bool Boolean value representing if the chart title will overlay the chart or not. 1.1
text string Represents the title text of a chart. 1.1
visible bool A boolean value the represents the visibility of a chart title object. 1.1

See property access examples.

Relationships

Relationship Type Description Req. Set
format ChartTitleFormat Represents the formatting of a chart title, which includes fill and font formatting. Read-only. 1.1

Methods

None

Method Details

Property access examples

Get the text of Chart Title from Chart1.

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

var title = chart.title;
title.load('text');
return ctx.sync().then(function() {
        console.log(title.text);
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});
});

Set the text of Chart Title to "My Chart" and Make it show on top of the chart without overlaying.

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

chart.title.text= "My Chart"; 
chart.title.visible=true;
chart.title.overlay=true;

return ctx.sync().then(function() {
        console.log("Char Title Changed");
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});
});

results matching ""

    No results matching ""