Charts
You'll author every chart kind ScaiScribe supports natively, then deliberately fall through to the image pipeline for one of the more exotic kinds. By the end you'll know which render_mode to pick for which situation.
Setup#
1 2 3 4 5 6 7 8 9 10 11 | |
Example 1 — Column chart in DOCX (native)#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
The output .docx contains word/charts/chart1.xml — a fully editable native Word chart. Double-click it in Word and you can change the data, restyle, or copy it to PowerPoint as a native chart.
Example 2 — Pie chart in PPTX (native via pptxgenjs)#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
PPTX uses pptxgenjs's native chart writer, which has broader coverage than the DOCX/XLSX hand-emitted path. All categorical and scatter kinds render natively.
Example 3 — Column chart in XLSX (native)#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | |
The result is an .xlsx with xl/charts/chart1.xml + a drawing anchor — a real native Excel chart that respects axis sorting, series colours, and double-click-to-edit.
Example 4 — Sankey chart in DOCX (image fallback)#
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
Sankey isn't in the DOCX native matrix. The auto render_mode (the default) detects this and renders an ECharts SVG instead — embedded as a <w:drawing> image in the .docx. Visually accurate, themed to your chart_palette, but not editable as a native chart.
When to override render_mode#
| Want | Set | Why |
|---|---|---|
| Default behaviour (native if possible, image otherwise) | "auto" or omit |
The right answer 95% of the time. |
| Force an image even for natively-supported kinds | "image" |
ECharts can be visually better than native for some kinds (e.g. PPTX scatter rendering can disappoint at small sizes). |
| Force a native chart and crash visibly if it can't | "native" |
You want the chart to be editable downstream, and would rather see an error than ship an image. |
A render_mode: "native" request that hits an unsupported kind produces a placeholder paragraph + a NATIVE_FALLBACK warning in the fidelity envelope. Not a render failure — a visible signal.
Theming chart colours#
Series colours come from the active theme's components.chart_palette. In office:
1 | |
Override per-series by setting series[i].color:
1 2 3 4 | |
Common patterns#
Stacked column#
1 2 3 4 5 6 7 8 9 10 | |
Native in PPTX and XLSX; image fallback in DOCX.
Line over time#
1 2 3 4 5 6 7 | |
Native in all three formats.
Scatter#
1 2 3 4 5 6 7 8 | |
Native in PPTX and XLSX; image in DOCX.
Gotchas#
- Series count vs. native rendering — native renderers handle up to ~6 series cleanly. Beyond that, even when "native" is supported, the legend and colours get cramped. Consider
render_mode: "image"for high-series-count charts to let ECharts compose the layout. - Empty data — a chart with no points renders as an empty chart frame (not an error). Validate upstream.
- Title visibility — omitting
titleis fine; the chart frame shrinks. Settingtitle: ""produces a chart with an empty title bar (Excel quirk). Prefer omission. - Categories type — categories must be strings even when they're conceptually numeric (years, IDs). Pass
["2024", "2025"], not[2024, 2025].
Where to next#
- Charts concept — full support matrix + theming.
- Themes — chart_palette and how it propagates.
- Reference → API —
Chartschema.