-
Notifications
You must be signed in to change notification settings - Fork 610
excel chart axis
goworm edited this page Jun 26, 2026
·
1 revision
Post-creation tuning of an existing chart's axes (category, value, secondary value, series), addressed by role.
Path: /{SheetName}/chart[N]/axis[@role=ROLE]
Where ROLE is one of category, value, value2, series.
- set - Update axis properties on an existing chart axis
- get - Read back axis attributes
There is no add or remove: axes are created and destroyed implicitly by chart-type changes.
Address the axis by role, then pass one or more --prop writes.
| Property | Required/Default | Description |
|---|---|---|
title |
Axis title text. Applies to all roles (category, value). Pass none to remove. |
|
visible |
Show or hide the axis (bool). Applies to all roles. | |
format |
Number format string for the axis (e.g. #,##0). |
|
labelRotation |
Tick label rotation in degrees. | |
majorGridlines |
Show or hide major gridlines (bool). Applies to all roles. | |
minorGridlines |
Show or hide minor gridlines (bool). Applies to all roles. | |
min |
Minimum scale of the value axis. Only valid for role=value or role=value2; ignored on category axes. |
|
max |
Maximum scale of the value axis. Only valid for role=value or role=value2; ignored on category axes. |
|
majorUnit |
Major tick interval on the value axis. Applies to role=value|value2. |
|
minorUnit |
Minor tick interval on the value axis. Applies to role=value|value2. |
|
logBase |
Logarithmic base for the value axis scale. Only valid for role=value or role=value2; ignored on category axes. |
|
dispUnits |
Display units for value axis labels. Applies to role=value|value2. One of: hundreds, thousands, tenThousands, hundredThousands, millions, tenMillions, hundredMillions, billions, trillions. |
get returns the writable keys above plus these read-only attributes:
| Attribute | Type | Description |
|---|---|---|
role |
string | Axis role token (lowercase) — identifies which axis this node represents. |
axisFont |
string | Axis text font name. |
axisMin |
number | Value-axis minimum (also surfaced via min). |
axisMax |
number | Value-axis maximum (also surfaced via max). |
axisNumFmt |
string | Axis number format code. |
axisOrientation |
string | Axis scaling orientation (e.g. maxMin when reversed). |
axisTitle |
string | Value-axis title (chart-level convenience; axis-by-role uses title). |
labelOffset |
number | Category axis label offset (% of default 100). |
tickLabelSkip |
number | Category axis label skip interval (>1 means tick labels are sparser). |
# Set the value-axis title and scale on chart 1
officecli set data.xlsx "/Sheet1/chart[1]/axis[@role=value]" \
--prop title="Revenue" \
--prop min=0 --prop max=1000
# Major/minor tick intervals on the value axis
officecli set data.xlsx "/Sheet1/chart[1]/axis[@role=value]" \
--prop majorUnit=20 --prop minorUnit=5
# Display units and number format on the value axis
officecli set data.xlsx "/Sheet1/chart[1]/axis[@role=value]" \
--prop dispUnits=thousands --prop format="#,##0"
# Logarithmic value-axis scale
officecli set data.xlsx "/Sheet1/chart[1]/axis[@role=value]" --prop logBase=10
# Category axis: title plus rotated tick labels
officecli set data.xlsx "/Sheet1/chart[1]/axis[@role=category]" \
--prop title="Quarter" --prop labelRotation=-45
# Toggle gridlines on the value axis
officecli set data.xlsx "/Sheet1/chart[1]/axis[@role=value]" \
--prop majorGridlines=true --prop minorGridlines=false
# Hide the secondary value axis
officecli set data.xlsx "/Sheet1/chart[1]/axis[@role=value2]" --prop visible=false
# Read back axis attributes
officecli get data.xlsx "/Sheet1/chart[1]/axis[@role=value]"- Axes are created and destroyed implicitly by chart-type changes — there is no direct
addorremove. - Extended charts (funnel, treemap, sunburst, boxWhisker, histogram) reject axis paths; use chart-level
setinstead. - At chart-creation time, configure axes via the chart's own
axis*props (axisMin,axisMax,axisTitle,axisFont, …).chart-axiscovers post-creation only. -
min/max/majorUnit/minorUnit/logBase/dispUnitsapply only to value axes (role=valueorrole=value2) and are ignored on category axes. -
lineWidth/lineDashset on an axis path apply to all plot-area series — use Chart series styling for series-specific line styling.
- Chart - Parent chart element
- Chart - set - Chart-level axis and styling props
- Chart - add - Create a chart and configure axes at creation time
- Excel Reference - All Excel elements
Based on OfficeCLI v1.0.119