Files
docx/docs/usage/chart-radar.md
T
DolanandClaude Opus 5.5 c169dd1a83 feat: live examples in the docs, which run, draw the document next to the code, and can be edited and downloaded (#3556)
* feat: live examples in the docs, which run, draw the document next to the code, and can be edited and downloaded

The docs' code examples were plain snippets, often fragments that couldn't run. A code block marked ```ts live is now
an example readers can see and change: the page runs it with docx, draws the document it makes next to the code with
docx-preview, and offers the .docx to download. Clicking the code opens an editor (Monaco) that knows docx's types,
the pages are drawn again as the code changes, and View closes the editor. Split, Code and Preview show the code and
the pages side by side, or one of them. The demos a page includes are live too.

Every example in the docs that builds or patches a document is now live: 443 of them, each a whole file with its
imports, so it runs as written. Code about other things, such as installing, bundlers or servers, stays plain.

Running them showed docs that were wrong, fixed here:
- Landscape: docx swaps a landscape page's width and height itself, so the docs' swapped sizes made a tall page
  marked as landscape
- Comments: `comments.children` takes plain objects, not `new Comment(...)`
- Custom properties are text only
- APIs that no longer exist: MathText, Row, `.then` on Packer.toStream, patchDocument(buffer, ...),
  createParagraph().heading1(), a border's `value`, TextRun's `.break()`
- The templates and patcher examples read files that aren't in the repository. They now patch the templates in
  demo/assets, or make their own

`npm run build.docs` copies docx's browser builds into docs/live-examples/lib, so the docs use the docx they
describe, and the Pages workflow runs it. The folder is gitignored, and cspell and ESLint skip it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TmyffPd5QMJYjXiMBQ3EnZ

* docs: the bullet examples draw a bullet, and the patcher's usage writes the patched document

"ὠ" is U+1F60, a Greek omega, since \u takes four hex digits, so the two live bullet examples on
the numbering page drew it as each item's bullet. They use "•" now. The patcher's usage example
now awaits patchDocument and writes the document it makes, as the example after it does.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TmyffPd5QMJYjXiMBQ3EnZ

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-28 13:00:29 +01:00

5.7 KiB

Radar Charts

A radar chart has a spoke for each category, and draws each series as a line around the spokes. Use it to compare several qualities at once, such as a team's skills.

Charts shows how to import ChartRun and add a chart to a document.

A Radar Chart

import { Document, Paragraph } from "docx";
import { ChartRun } from "docx/charts";

const doc = new Document({
    sections: [
        {
            children: [
                new Paragraph({
                    children: [
                        new ChartRun({
                            type: "radar",
                            title: "Skills",
                            categories: ["Speed", "Strength", "Range", "Stamina", "Skill"],
                            series: [
                                { name: "Alice", values: [4, 3, 5, 2, 4] },
                                { name: "Bob", values: [3, 5, 2, 4, 3] },
                            ],
                            valueAxis: { minimum: 0, maximum: 5, interval: 1 },
                        }),
                    ],
                }),
            ],
        },
    ],
});
  • The first category's spoke points up, and the others go round clockwise.
  • Each value is a point on its category's spoke: the further out, the bigger the value. The rings are the value axis' gridlines.
  • A null value leaves a gap in its line.

Markers and Filled Radar Charts

  • markers: true draws a circle at each point, as Word's "Radar with Markers" does. Markers can have a shape and size of their own. See Markers.
  • filled: true fills the area inside each series' line, as Word's "Filled Radar" does. A filled radar chart has no markers, and its series no lines.
import { Document, Paragraph } from "docx";
import { ChartRun } from "docx/charts";

const doc = new Document({
    sections: [
        {
            children: [
                new Paragraph({
                    children: [
                        new ChartRun({
                            type: "radar",
                            categories: ["Speed", "Strength", "Range", "Stamina", "Skill"],
                            series: [{ name: "Alice", values: [4, 3, 5, 2, 4] }],
                            filled: true,
                        }),
                    ],
                }),
            ],
        },
    ],
});

Axes

  • categoryAxis is the labels at the end of the spokes, and the spokes themselves, which are its gridlines.
  • valueAxis runs up the first spoke. Its gridlines are the rings, and it takes a range and a number format as any value axis does.

See Chart Axes.

Options

Property Type Notes Description
type "radar" Required
categories (string | number)[] Required The spokes, in order. See Chart Data
series RadarChartSeries[] Required { name, values, color?, markers?, line?, dataLabels?, pointLabels? }, with a value or null for each category
markers boolean | ChartMarker Optional A marker at each point. Default false. See Markers
filled boolean Optional Fills each series' area. Default false
categoryAxis ChartAxis Optional The spokes and their labels. See Chart Axes
valueAxis ChartValueAxis Optional The axis up the first spoke. See Chart Axes
dataLabels ChartDataLabels Optional See Chart Data Labels. A radar chart's labels have no position
emptyValues "gap" | "zero" | "connect" Optional How null is drawn. Default "gap". See Empty Values
title string | ChartTitle Optional See Chart Titles and Legends
legend false | ChartLegend Optional See Chart Titles and Legends
transformation { width, height } Optional See Chart Size and Position
floating IFloating Optional See Chart Size and Position
altText DocPropertiesOptions Optional See Chart Size and Position

Chart Fonts and Fills shows the options every chart has for its text, background and border.