plotilla 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/README.md +82 -2
- package/data/boundaries/canada_provinces.geojson +1 -0
- package/data/boundaries/eu_countries.geojson +1 -0
- package/data/boundaries/us_states.geojson +1 -0
- package/data/boundaries/world_countries.geojson +1 -0
- package/package.json +62 -4
- package/src/colour/colour_scale.ts +80 -0
- package/src/colour/palette.ts +220 -0
- package/src/examples/example_figures.ts +320 -0
- package/src/fields/axis_fields.ts +32 -0
- package/src/fields/colour_fields.ts +40 -0
- package/src/fields/column_fields.ts +64 -0
- package/src/fields/common_fields.ts +13 -0
- package/src/fields/decide_plot_axes.ts +77 -0
- package/src/fields/marker_fields.ts +16 -0
- package/src/figure/plot_figure.ts +67 -0
- package/src/figure/resolve_plot_figure.ts +47 -0
- package/src/figure/validate_plot_figure.ts +412 -0
- package/src/map/boundary_sets.ts +116 -0
- package/src/map/check_map_layers.ts +32 -0
- package/src/map/fetch_region_outlines.ts +48 -0
- package/src/map/geojson.ts +174 -0
- package/src/map/map_layers.ts +108 -0
- package/src/model/check_axis_shows_years.ts +58 -0
- package/src/model/map_model.ts +238 -0
- package/src/model/panel_layout.ts +171 -0
- package/src/model/panel_model.ts +85 -0
- package/src/model/plot_model.ts +347 -0
- package/src/model/statistics.ts +134 -0
- package/src/plots/bar_plot.ts +36 -0
- package/src/plots/box_plot.ts +26 -0
- package/src/plots/density_plot.ts +29 -0
- package/src/plots/heatmap_plot.ts +24 -0
- package/src/plots/histogram_plot.ts +29 -0
- package/src/plots/line_plot.ts +29 -0
- package/src/plots/map_plot.ts +46 -0
- package/src/plots/pie_plot.ts +23 -0
- package/src/plots/scatter_plot.ts +32 -0
- package/src/renderers/echarts_map.ts +194 -0
- package/src/renderers/echarts_options.ts +317 -0
- package/src/renderers/plotly_map.ts +170 -0
- package/src/renderers/plotly_options.ts +318 -0
- package/src/table/check_column.ts +34 -0
- package/src/table/check_values_have_spread.ts +47 -0
- package/src/table/compute_quantile.ts +23 -0
- package/src/table/data_table.ts +83 -0
- package/src/table/density_bandwidth.ts +94 -0
- package/src/table/find_line_fit.ts +44 -0
- package/src/table/get_number_range.ts +21 -0
- package/src/table/group_rows.ts +71 -0
- package/src/table/list_categories.ts +17 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Idin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,83 @@
|
|
|
1
|
-
#
|
|
1
|
+
# plotilla
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Plots from one spec for AI agents: validation an agent can read, statistics,
|
|
4
|
+
maps, and ECharts or Plotly output. Pulled out of
|
|
5
|
+
[scribble.tube](https://scribble.tube) so any MCP server can plot.
|
|
6
|
+
|
|
7
|
+
## Why it exists
|
|
8
|
+
|
|
9
|
+
An agent describes a chart once, as data: a table, and one or more plots that
|
|
10
|
+
name its columns (`{ type: "line", x: "month", y: "sales", colour: "store" }`).
|
|
11
|
+
plotilla checks that description with errors written for the agent to act
|
|
12
|
+
on, works out everything a chart needs (bins, densities, box statistics,
|
|
13
|
+
trend lines, colours, map joins), and builds the options for ECharts or
|
|
14
|
+
Plotly. The same spec draws the same chart in either library, in a light or
|
|
15
|
+
dark theme.
|
|
16
|
+
|
|
17
|
+
Keeping this in one package means every server that plots speaks the same
|
|
18
|
+
spec, so an agent learns it once and a fix reaches them all.
|
|
19
|
+
|
|
20
|
+
## What a host does
|
|
21
|
+
|
|
22
|
+
plotilla never touches the network or the disk itself. A host passes in how
|
|
23
|
+
to do both:
|
|
24
|
+
|
|
25
|
+
- **`resolvePlotFigure(figure, { limits, size, loadBoundarySet, fetchGeoJson })`**
|
|
26
|
+
checks a figure, fills in every default, loads the outlines its map layers
|
|
27
|
+
name, and returns it with notes for the agent (region names that matched nothing, what a renderer cannot
|
|
28
|
+
draw). `loadBoundarySet` reads the built-in outline sets, which ship in
|
|
29
|
+
`data/boundaries/` (see `createBoundaryLoader`). `fetchGeoJson` fetches
|
|
30
|
+
outlines from an address the agent gave, with the host's own rules on
|
|
31
|
+
addresses, size and identity. `limits` (the most plots, rows and histogram
|
|
32
|
+
bins) is the host's own configuration: plotilla has no opinion on them.
|
|
33
|
+
`size` is the `{ width, height }` in pixels it will draw at: a figure
|
|
34
|
+
that cannot fit is refused here, before anything is drawn.
|
|
35
|
+
- **`buildFigureModel(figure, { theme })`**, then **`buildEChartsOption(model, { size })`**
|
|
36
|
+
or **`buildPlotlyFigure(model, { size })`**, give what the chart library draws.
|
|
37
|
+
`size` is `{ width, height }` in pixels, the size the host draws at: every
|
|
38
|
+
gap is sized from the labels and legend it must hold, so a figure that
|
|
39
|
+
changes size is built again. A figure too small for its content is
|
|
40
|
+
refused, naming the size it needs.
|
|
41
|
+
|
|
42
|
+
An ECharts option can carry three things for the page, under keys exported
|
|
43
|
+
from `renderers/echarts_options`: maps to register first (`MAPS_OPTION_KEY`),
|
|
44
|
+
a notice for the person (`NOTICE_OPTION_KEY`), and axes whose numbers are
|
|
45
|
+
years (`PLAIN_NUMBERS_LABEL_KEY`). The page acts on each, then removes it.
|
|
46
|
+
|
|
47
|
+
Each module is imported by its own path (`plotilla/figure/resolve_plot_figure`,
|
|
48
|
+
`plotilla/renderers/echarts_options`): there is no index that re-exports
|
|
49
|
+
everything.
|
|
50
|
+
|
|
51
|
+
## One interface for every plot
|
|
52
|
+
|
|
53
|
+
Every field is defined once, with zod, and each plot type takes the shared
|
|
54
|
+
groups it uses, so a field means the same on every plot and in either
|
|
55
|
+
renderer. A field that does not apply is refused, naming it. The JSON Schema
|
|
56
|
+
a host gives its agents comes from the same definitions
|
|
57
|
+
(`PLOT_FIGURE_SCHEMA` in `figure/plot_figure`). The rule is
|
|
58
|
+
`.claude/rules/plot_interface.md`; `tests/figure/plot_figure.test.ts`
|
|
59
|
+
enforces it.
|
|
60
|
+
|
|
61
|
+
## The catalogue
|
|
62
|
+
|
|
63
|
+
`playbook/visualisation_catalogue.md` lists every visualisation to support,
|
|
64
|
+
each pictured in Plotly and in ECharts. The pictures are drawn by
|
|
65
|
+
`scripts/playbook/plotly` (Python, `uv run --project scripts/playbook/plotly`) and `scripts/playbook/echarts`
|
|
66
|
+
(`npx tsx`), which share one palette, size and font.
|
|
67
|
+
|
|
68
|
+
## The gallery
|
|
69
|
+
|
|
70
|
+
`src/examples/example_figures.ts` has every plot type in a simple form and a
|
|
71
|
+
complex one. To see them all, drawn with either library:
|
|
72
|
+
|
|
73
|
+
```sh
|
|
74
|
+
npx tsx scripts/build_gallery.ts --output dist/gallery.html
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Open the file, or add `#plotly` to its address to start with Plotly.
|
|
78
|
+
|
|
79
|
+
## The built-in outlines
|
|
80
|
+
|
|
81
|
+
`data/boundaries/` holds world countries, US states, Canadian provinces and
|
|
82
|
+
EU countries, built from Natural Earth (public domain) by
|
|
83
|
+
`npx tsx scripts/build_boundaries.ts`.
|