plotagents 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.md +5 -1
- package/README.md +18 -1
- package/bin/plotagents.js +3 -1
- package/dist/plotagents-geo.js +1 -1
- package/dist/plotagents.js +1857 -110
- package/docs/charts.md +86 -1
- package/docs/es/agents.md +102 -0
- package/docs/es/api.md +172 -0
- package/docs/es/charts.md +436 -0
- package/docs/es/colorscales.md +46 -0
- package/docs/es/dashboards.md +79 -0
- package/docs/es/getting-started.md +142 -0
- package/docs/es/rendering.md +47 -0
- package/docs/es/themes.md +116 -0
- package/index.d.ts +92 -8
- package/package.json +3 -2
- package/schema.json +359 -9
- package/skills/plotagents/SKILL.md +105 -0
- package/src/charts/bar.js +13 -5
- package/src/charts/chord.js +3 -1
- package/src/charts/choropleth.js +3 -1
- package/src/charts/corr.js +512 -0
- package/src/charts/dist.js +2 -1
- package/src/charts/donut.js +3 -1
- package/src/charts/kpi.js +2 -2
- package/src/charts/line.js +19 -7
- package/src/charts/network.js +13 -8
- package/src/charts/pointmap.js +9 -6
- package/src/charts/regplot.js +9 -3
- package/src/charts/sankey.js +1 -1
- package/src/charts/scatter.js +4 -2
- package/src/charts/sunburst.js +2 -2
- package/src/charts/table.js +882 -0
- package/src/charts/treemap.js +2 -2
- package/src/charts/wordcloud.js +17 -3
- package/src/colorscales.js +12 -1
- package/src/dashboard.js +21 -8
- package/src/data.js +2 -0
- package/src/facet.js +4 -3
- package/src/format.js +36 -13
- package/src/frame.js +8 -5
- package/src/geo/projection.js +4 -2
- package/src/hierarchy.js +6 -0
- package/src/i18n.js +107 -0
- package/src/index.js +17 -4
- package/src/infer.js +9 -1
- package/src/lint.js +66 -4
- package/src/runtime.js +94 -6
- package/src/scale.js +3 -2
- package/src/schema.js +54 -11
- package/src/stats.js +5 -3
- package/src/svg.js +4 -1
- package/src/text.js +5 -0
package/AGENTS.md
CHANGED
|
@@ -14,7 +14,7 @@ const svg = plot({ type, data, x, y, series, title, subtitle, source });
|
|
|
14
14
|
3. **Always set `source`.** If the data is made up, use `source: "illustrative data"`.
|
|
15
15
|
4. `data` is a list of rows (`[{ region: "Biobío", sales: 1240 }]`). For a wide table, pass `y: ["revenue", "costs"]`.
|
|
16
16
|
5. Call `safePlot(spec)` as your tool: it never throws and returns `errors`, `warnings` and `suggestions`, each with a `fix`. If `ok` is `false`, fix the spec and call again.
|
|
17
|
-
6. Set `locale: "en"` for English number formats (default is Spanish: `1.234,5`).
|
|
17
|
+
6. Set `locale: "en"` for English number formats (default is Spanish: `1.234,5`); also `"pt"`, `"fr"`, `"de"`, or `"auto"` to recognize it from the text. Tables recognize it on their own.
|
|
18
18
|
|
|
19
19
|
## Which type
|
|
20
20
|
|
|
@@ -30,6 +30,8 @@ const svg = plot({ type, data, x, y, series, title, subtitle, source });
|
|
|
30
30
|
| Exponential growth | `line` + `yScale: "log"` | |
|
|
31
31
|
| Relationship between two measures | `regplot` (fit + CI) / `scatter` / `bubble` | `x`, `y`, `hue?`, `size?`, `label?` |
|
|
32
32
|
| Relationship + marginals | `jointplot` | `x`, `y` |
|
|
33
|
+
| Which measures move together | `corr` (`correlation`) | `vars?` (default: every numeric field), `method?` (`"spearman"`), `alpha?: 0.05`; `cluster: true` or `type: "clustermap"` groups them with a dendrogram |
|
|
34
|
+
| Every pair of measures at once | `pairplot` (`splom`) | `vars` (3–6), `hue?`, `corner?`, `kind?: "reg"` |
|
|
33
35
|
| Distribution of one measure | `hist` (`kde: true`), `kde`, `ecdf` | `x`, `hue?` |
|
|
34
36
|
| Distribution by category | `box`, `violin`, `strip`, `swarm` | `x` category, `y` measure, `hue?` |
|
|
35
37
|
| Multi-dimensional profile | `radar` | `axis`, `value`, `series` (≤ 4 series) |
|
|
@@ -44,6 +46,7 @@ const svg = plot({ type, data, x, y, series, title, subtitle, source });
|
|
|
44
46
|
| A process with decisions | `flowchart` | `nodes` (`type`, `lane`), `edges` (`label`) |
|
|
45
47
|
| Flows between stages | `sankey` | `from`, `to`, `value` |
|
|
46
48
|
| One or more numbers | `kpi` | `items: [{ label, value, delta, period, trend, target, good }]` |
|
|
49
|
+
| Exact values to look up | `table` | `columns?: [field \| { field, type, label, format, good, target }]`, `sortBy?`, `total?`, `group?`; types `bar`, `delta`, `heat`, `sparkline`, `progress`, `badge`, `check` are inferred when omitted |
|
|
47
50
|
| What comes up most in text | `wordcloud` | `text` (field or raw text), `value?`, `series?`; prefer `bar` + `top` to compare exactly |
|
|
48
51
|
|
|
49
52
|
seaborn names work (`histplot`, `kdeplot`, `boxplot`, `violinplot`, `lmplot`, `stripplot`, `swarmplot`, `pointplot`), and `hue` is an alias of `series`. Leave `type` out to infer it from the data.
|
|
@@ -59,6 +62,7 @@ seaborn names work (`histplot`, `kdeplot`, `boxplot`, `violinplot`, `lmplot`, `s
|
|
|
59
62
|
- `refLines: [{ y: 600, label: "Target" }]` and `annotations: [{ x: "2024-01", label: "New branch" }]`.
|
|
60
63
|
- `format: "percent" | "currency" | "compact" | "integer"` or `{ prefix, suffix, decimals }`.
|
|
61
64
|
- `xScale` / `yScale: "log"`.
|
|
65
|
+
- `table`: give a title that states the finding like any chart. More than 15 rows paginate in tens (`pageSize`), phones get one card per row, and the browser adds sort, search and paging. Use `good: "down"` on costs so ▲ turns red, `progress` with `target: "budget"` for spent vs budget, and `total: true` for a totals row. Keep 4–7 columns.
|
|
62
66
|
- `theme: "noche"` or a JSON object (`{ extends, categorical, type, marks, font }`); `palette: [...]` for your own colors.
|
|
63
67
|
- `font: "Poppins"` and `textScale: 1.5` (presentation mode); `configure({ font, textScale })` sets them for every chart.
|
|
64
68
|
- `network` + `focus: "node id"`: center a node and highlight its neighbors.
|
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ Agents are good at data and bad at charts: dual axes, 12-slice pies, titles that
|
|
|
55
55
|
|---|---|
|
|
56
56
|
| Compare categories | `bar` (`barplot` with confidence intervals), `count` (`countplot`) |
|
|
57
57
|
| Change over time | `line` (`lineplot`, `ci` for a confidence band), `area` |
|
|
58
|
-
| Relationships | `scatter`, `bubble`, `regplot` (`lmplot`), `residplot`, `jointplot` |
|
|
58
|
+
| Relationships | `scatter`, `bubble`, `regplot` (`lmplot`), `residplot`, `jointplot`, `corr` (correlation matrix; `clustermap` with a dendrogram), `pairplot` (`splom`) |
|
|
59
59
|
| Profiles | `radar` (`spider`) |
|
|
60
60
|
| Distributions | `hist` (`histplot`), `kde` (`kdeplot`), `ecdf`, `box` (`boxplot`), `violin`, `strip`, `swarm` (`beeswarm`), `point` (`pointplot`) |
|
|
61
61
|
| Part-to-whole | `treemap` (any depth, with % change over time), `sunburst`, `donut`, `pie` |
|
|
@@ -65,6 +65,7 @@ Agents are good at data and bad at charts: dual axes, 12-slice pies, titles that
|
|
|
65
65
|
| Populations | `pyramid` |
|
|
66
66
|
| Grids | `heatmap` |
|
|
67
67
|
| Numbers | `kpi` |
|
|
68
|
+
| Exact values | `table`: an indicator per column (data bars, ▲/▼ changes, cell colors, sparklines, progress against a target, status pills, ✓), pages of 10, cards on phones, click-to-sort and search in the browser, language recognized from the text |
|
|
68
69
|
| Text | `wordcloud` (words sized by frequency, or raw text to count) |
|
|
69
70
|
| Dashboards | `dashboard({ title, kpis, charts, filters })`: a whole HTML dashboard with best-practice layout ([guide](docs/dashboards.md)) |
|
|
70
71
|
|
|
@@ -168,6 +169,22 @@ import { plot, safePlot, lint, describe, render, toHTML, schema, toolDefinition,
|
|
|
168
169
|
|
|
169
170
|
In the browser without a bundler, `<script src="dist/plotagents.js"></script>` defines `window.plotagents`. Full types are in [`index.d.ts`](index.d.ts) and every option in [`schema.json`](schema.json).
|
|
170
171
|
|
|
172
|
+
## Teach your AI to use it (Agent Skill)
|
|
173
|
+
|
|
174
|
+
[`skills/plotagents/SKILL.md`](skills/plotagents/SKILL.md) tells any AI assistant to make its charts with plotagents, with the essentials built in. It also checks npm for a newer release and reads the latest guide when there is one.
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
npx skills add carlosnavarreteliz/plotagents
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
That works for Claude Code, Cursor, Codex and other agents that read skills. By hand, for Claude Code:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
mkdir -p ~/.claude/skills/plotagents && curl -sL https://raw.githubusercontent.com/carlosnavarreteliz/plotagents/master/skills/plotagents/SKILL.md -o ~/.claude/skills/plotagents/SKILL.md
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
In the Claude app, zip the `skills/plotagents` folder and upload it under Settings → Capabilities → Skills.
|
|
187
|
+
|
|
171
188
|
## As an agent tool
|
|
172
189
|
|
|
173
190
|
```js
|
package/bin/plotagents.js
CHANGED
|
@@ -8,6 +8,8 @@ import { plot, toHTML, lint, schema, toolDefinition, describe, dashboard, lintDa
|
|
|
8
8
|
// `plotagents … | head` closes the pipe early: exit quietly instead of crashing.
|
|
9
9
|
for (const stream of [process.stdout, process.stderr]) {
|
|
10
10
|
stream.on('error', (e) => { if (e && e.code === 'EPIPE') process.exit(0); throw e; });
|
|
11
|
+
// Escritura bloqueante: process.exit() no corta una salida larga (> 64 KB) en un pipe.
|
|
12
|
+
stream._handle?.setBlocking?.(true);
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
const args = process.argv.slice(2);
|
|
@@ -47,7 +49,7 @@ try { raw = input ? readFileSync(input, 'utf8') : readFileSync(0, 'utf8'); } cat
|
|
|
47
49
|
let spec;
|
|
48
50
|
try { spec = JSON.parse(raw); } catch (e) { console.error('El spec no es JSON válido:', e.message); process.exit(2); }
|
|
49
51
|
|
|
50
|
-
const isDashboard = (s) => !!s && typeof s === 'object' && !Array.isArray(s) && Array.isArray(s.charts);
|
|
52
|
+
const isDashboard = (s) => !!s && typeof s === 'object' && !Array.isArray(s) && (Array.isArray(s.charts) || (Array.isArray(s.kpis) && s.type === undefined));
|
|
51
53
|
|
|
52
54
|
if (flag('--lint')) {
|
|
53
55
|
const list = Array.isArray(spec) ? spec : [spec];
|
package/dist/plotagents-geo.js
CHANGED