--- title: "Pie chart from a few numbers" description: "Turn a few numbers into a pie chart with shares and a legend, from a link." tool: pie-chart category: Planning tags: [tool, planning, chart] --- ## What this is for **Use it** when you want to see how a total splits into parts, for example todos by state. **Skip it** when you need exact values on many categories; use a table. The page is filled in from its address, so a person or an AI model can build the link and you only have to open it. ## Link to a filled-in view Put the values in the address after `#`. The part after `#` stays in your browser and is never sent to a server, so it is the right place for private data. `?` works too. Two links to the same example: {{< example-links "pie-chart" >}} Add `mode=present` to any link to show only the result. | Parameter | What it is | |---|---| | `data` | Values: one name=number per line, or separated by commas. For example: Done=5, Pending=3, Blocked=1. Percent signs and spaces are fine. Write 1000, or use one value per line, for thousands. | Without JavaScript, the `data` value in the link is the table: each `name=number` pair is one slice, and its share is its number divided by the total. ### Optional text Every tool also accepts five optional text parameters. Leave any of them out and nothing is drawn for it, so there is no empty heading or gap. | Parameter | What it is | |---|---| | `title` | A heading above the result. | | `description` | One or two sentences on what the result shows. | | `summary` | A headline for people. Left out, the tool writes its own. | | `legend` | How to read it, for example "Blue is done". | | `note` | A footnote: a source, a date or a caveat. | Text is cut to a sensible length (100 to 300 characters) and shown as plain text, so markup in it is never run. ## For agents Build the link above with your own values and give it to the user. Or run the logic without a browser: ```bash node cli.mjs pie-chart '{"data": "Done=5, Pending=3, Blocked=1"}' ``` The result is JSON: `ok`, `summary`, `matches` (a list of `{id, label, detail}`) and `view`, the data the page draws. A value that cannot be used gives `ok: false` and a `summary` that says what to fix. Every example in the data file is checked by `npm test`. ## Related - [Tools home](/): all the tools, and the registry that lists their parameters.