ChartAxis Object (JavaScript API for Excel)

Represents a single axis in a chart.

Properties

Property Type Description Req. Set
majorUnit object Represents the interval between two major tick marks. Can be set to a numeric value or an empty string. The returned value is always a number. 1.1
maximum object Represents the maximum value on the value axis. Can be set to a numeric value or an empty string (for automatic axis values). The returned value is always a number. 1.1
minimum object Represents the minimum value on the value axis. Can be set to a numeric value or an empty string (for automatic axis values). The returned value is always a number. 1.1
minorUnit object Represents the interval between two minor tick marks. "Can be set to a numeric value or an empty string (for automatic axis values). The returned value is always a number. 1.1

See property access examples.

Relationships

Relationship Type Description Req. Set
format ChartAxisFormat Represents the formatting of a chart object, which includes line and font formatting. Read-only. 1.1
majorGridlines ChartGridlines Returns a gridlines object that represents the major gridlines for the specified axis. Read-only. 1.1
minorGridlines ChartGridlines Returns a Gridlines object that represents the minor gridlines for the specified axis. Read-only. 1.1
title ChartAxisTitle Represents the axis title. Read-only. 1.1

Methods

None

Method Details

Property access examples

Get the maximum of Chart Axis from Chart1

Excel.run(function (ctx) { 
    var chart = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1"); 
    var axis = chart.axes.valueAxis;
    axis.load('maximum');
    return ctx.sync().then(function() {
            console.log(axis.maximum);
    });
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});

Set the maximum, minimum, majorunit, minorunit of valueaxis.

Excel.run(function (ctx) { 
    var chart = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1"); 
    chart.axes.valueAxis.maximum = 5;
    chart.axes.valueAxis.minimum = 0;
    chart.axes.valueAxis.majorUnit = 1;
    chart.axes.valueAxis.minorUnit = 0.2;
    return ctx.sync().then(function() {
            console.log("Axis Settings Changed");
    });
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});
m("Chart1"); var axis = chart.axes.valueAxis; axis.load('maximum'); return ctx.sync().then(function() { console.log(axis.maximum); }); }).catch(function(error) { console.log("Error: " + error); if (error instanceof OfficeExtension.Error) { console.log("Debug info: " + JSON.stringify(error.debugInfo)); } });

Set the maximum, minimum, majorunit, minorunit of valueaxis.

Excel.run(function (ctx) { 
    var chart = ctx.workbook.worksheets.getItem("Sheet1").charts.getItem("Chart1"); 
    chart.axes.valueAxis.maximum = 5;
    chart.axes.valueAxis.minimum = 0;
    chart.axes.valueAxis.majorUnit = 1;
    chart.axes.valueAxis.minorUnit = 0.2;
    return ctx.sync().then(function() {
            console.log("Axis Settings Changed");
    });
}).catch(function(error) {
        console.log("Error: " + error);
        if (error instanceof OfficeExtension.Error) {
            console.log("Debug info: " + JSON.stringify(error.debugInfo));
        }
});