blockcharts 0.0.0-stage → 0.0.1
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 +287 -2
- package/package.json +87 -4
- package/release/bc.d.ts +764 -0
- package/release/blocks/guide.axis.js +3 -0
- package/release/blocks/guide.grid.js +3 -0
- package/release/blocks/guide.kpi.js +3 -0
- package/release/blocks/guide.legend.js +3 -0
- package/release/blocks/interaction.animate.js +3 -0
- package/release/blocks/interaction.brush.js +3 -0
- package/release/blocks/interaction.crosshair.js +3 -0
- package/release/blocks/interaction.legend-filter.js +3 -0
- package/release/blocks/interaction.tooltip.js +3 -0
- package/release/blocks/interaction.zoom-controls.js +3 -0
- package/release/blocks/interaction.zoom.js +3 -0
- package/release/blocks/lib.columns.js +3 -0
- package/release/blocks/lib.curve.js +3 -0
- package/release/blocks/lib.pointer.js +3 -0
- package/release/blocks/lib.stats.js +3 -0
- package/release/blocks/lib.ticks.js +3 -0
- package/release/blocks/lib.view.js +3 -0
- package/release/blocks/mark.arc.js +3 -0
- package/release/blocks/mark.area.js +3 -0
- package/release/blocks/mark.boxplot.js +3 -0
- package/release/blocks/mark.candlestick.js +3 -0
- package/release/blocks/mark.line.js +3 -0
- package/release/blocks/mark.point.js +3 -0
- package/release/blocks/mark.polygon.js +3 -0
- package/release/blocks/mark.rect.js +3 -0
- package/release/blocks/mark.rule.js +3 -0
- package/release/blocks/mark.sankey.js +3 -0
- package/release/blocks/mark.text.js +3 -0
- package/release/blocks/mark.violin.js +3 -0
- package/release/blocks/renderer.canvas.js +3 -0
- package/release/blocks/renderer.svg.js +3 -0
- package/release/blocks/scale.band.js +3 -0
- package/release/blocks/scale.color.js +3 -0
- package/release/blocks/scale.linear.js +3 -0
- package/release/blocks/scale.log.js +3 -0
- package/release/blocks/scale.sequential.js +3 -0
- package/release/blocks/scale.size.js +3 -0
- package/release/blocks/scale.time.js +3 -0
- package/release/blocks/transform.aggregate.js +3 -0
- package/release/blocks/transform.bin.js +3 -0
- package/release/blocks/transform.calculate.js +3 -0
- package/release/blocks/transform.calendar.js +3 -0
- package/release/blocks/transform.contour.js +3 -0
- package/release/blocks/transform.decimate.js +3 -0
- package/release/blocks/transform.density.js +3 -0
- package/release/blocks/transform.filter.js +3 -0
- package/release/blocks/transform.fold.js +3 -0
- package/release/blocks/transform.funnel.js +3 -0
- package/release/blocks/transform.hexbin.js +3 -0
- package/release/blocks/transform.highlight.js +3 -0
- package/release/blocks/transform.marimekko.js +3 -0
- package/release/blocks/transform.quartiles.js +3 -0
- package/release/blocks/transform.sankey.js +3 -0
- package/release/blocks/transform.sort.js +3 -0
- package/release/blocks/transform.stack.js +3 -0
- package/release/blocks/transform.treemap.js +3 -0
- package/release/blocks/transform.waterfall.js +3 -0
- package/release/blocks/transform.window.js +3 -0
- package/release/core.js +5 -0
- package/release/kits/basic.d.mts +3 -0
- package/release/kits/basic.d.ts +3 -0
- package/release/kits/basic.js +64 -0
- package/release/kits/basic.mjs +64 -0
- package/release/kits/composition.d.mts +3 -0
- package/release/kits/composition.d.ts +3 -0
- package/release/kits/composition.js +106 -0
- package/release/kits/composition.mjs +106 -0
- package/release/kits/dashboard.d.mts +3 -0
- package/release/kits/dashboard.d.ts +3 -0
- package/release/kits/dashboard.js +100 -0
- package/release/kits/dashboard.mjs +100 -0
- package/release/kits/full.d.mts +3 -0
- package/release/kits/full.d.ts +3 -0
- package/release/kits/full.js +181 -0
- package/release/kits/full.mjs +181 -0
- package/release/kits/timeseries.d.mts +3 -0
- package/release/kits/timeseries.d.ts +3 -0
- package/release/kits/timeseries.js +94 -0
- package/release/kits/timeseries.mjs +94 -0
- package/release/loader.js +3 -0
- package/release/manifest.json +1038 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Aleksandr Lisin
|
|
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,288 @@
|
|
|
1
|
-
#
|
|
1
|
+
# blockcharts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**[blockcharts.online](https://blockcharts.online)** · [the principles](docs/spec/principles.md) · [the documentation](docs/README.md)
|
|
4
|
+
|
|
5
|
+
**Atomic charts for HTML dashboards: a page carries only the chart code it needs. Nothing more.**
|
|
6
|
+
|
|
7
|
+
blockcharts is a chart library cut into atoms — a scale, a bar, an axis, a tooltip, each a block of <!-- build:block-range -->0.4–12 KB<!-- /build -->.
|
|
8
|
+
A page gets the core (about <!-- build:core-gzip -->12 KB<!-- /build --> gzipped) and exactly the blocks its own charts use, never the whole library;
|
|
9
|
+
anything can be customized, down to blocks of your own. The agent skill turns a table or a CSV file into one
|
|
10
|
+
light `.html` report with interactive charts that opens offline and can be emailed.
|
|
11
|
+
|
|
12
|
+
## Install the skill
|
|
13
|
+
|
|
14
|
+
**Claude Code** — from this repository, which is a plugin marketplace:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
/plugin marketplace add boligolov/blockcharts
|
|
18
|
+
/plugin install blockcharts@blockcharts
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
It updates by itself once auto-update is on for the marketplace (`/plugin` → *Marketplaces*), or by hand with
|
|
22
|
+
`claude plugin update blockcharts@blockcharts`.
|
|
23
|
+
|
|
24
|
+
**Claude.ai and Claude Desktop** — download **[blockcharts.skill](https://blockcharts.online/blockcharts.skill)**
|
|
25
|
+
and upload it under *Settings → Capabilities → Skills* (skills need code execution enabled).
|
|
26
|
+
|
|
27
|
+
**Any other agent that reads skill folders** — copy [`skills/blockcharts/`](skills/blockcharts/) into its
|
|
28
|
+
skills folder (`~/.claude/skills/` for Claude Code). It needs Node.js 22+.
|
|
29
|
+
|
|
30
|
+
Then ask — *"an HTML report of monthly revenue by region from sales.csv"*, *"a dashboard of these KPIs"*.
|
|
31
|
+
Scopes and details: [docs/skill.md](docs/skill.md).
|
|
32
|
+
|
|
33
|
+
## How it works
|
|
34
|
+
|
|
35
|
+
Charts are drawn by small independent **blocks** (`scale.time`, `mark.rect`, `guide.axis`,
|
|
36
|
+
`interaction.zoom`, …). A chart is a JSON spec that names them; the blocks a page needs are read from its
|
|
37
|
+
specs, closed over their dependencies, and only those go into the page: a bar chart with labels and a tooltip
|
|
38
|
+
carries <!-- build:bar -->10 of the 58 blocks, 71 KB of code instead of 214<!-- /build -->; a whole executive dashboard
|
|
39
|
+
(KPI tiles, a trend, a donut, a waterfall, a funnel, animated) carries <!-- build:dashboard-blocks -->24<!-- /build -->. Nobody lists blocks by hand, so the list is never too long.
|
|
40
|
+
|
|
41
|
+
The agent never writes chart code. It writes the JSON, and a composer bundled with the skill checks every
|
|
42
|
+
chart against the real data, reports each mistake with its place in the JSON, and only then writes the page.
|
|
43
|
+
|
|
44
|
+
**Customizable at every level**: block parameters (formats, locales, axes, tooltips), CSS variables and
|
|
45
|
+
classes (brand colors, dark mode, print), your own set of blocks (a kit per page, or the loader), functions
|
|
46
|
+
by name (`BC.defineFn`), and blocks of your own — a small script calling `BC.define`, the same contract the
|
|
47
|
+
built-in blocks use ([an example](https://blockcharts.online/embed/block/)).
|
|
48
|
+
|
|
49
|
+
## The principles behind it
|
|
50
|
+
|
|
51
|
+
[`docs/spec/principles.md`](docs/spec/principles.md) — *blockcharts principles v<!-- build:principles-version -->1.1<!-- /build -->*: how a report is built
|
|
52
|
+
from blocks so that a page carries exactly the code its charts need — and what follows from that.
|
|
53
|
+
|
|
54
|
+
- **Exactly what the charts need, nothing more** (§1): blocks are chosen mechanically from the specs, never by hand.
|
|
55
|
+
- **Blocks are atoms** (§2): one role, one job; a bar chart is `band + linear + rect`, a new chart is a recipe.
|
|
56
|
+
- **Customizable at every level** (§3): parameters, CSS, your own set of blocks, functions, your own blocks.
|
|
57
|
+
- **The page is the product** (§4): one HTML file that opens from disk, offline, anywhere.
|
|
58
|
+
- **The chart is data** (§5–6), **checked before it is written** (§7).
|
|
59
|
+
- **Heavy data stays light** (§8), **same input, same bytes** (§9), **nothing leaves the page** (§10).
|
|
60
|
+
- **One set of files, three ways in** (§11) and the **requirements** for pages, blocks and composers (§12).
|
|
61
|
+
|
|
62
|
+
## The library for your own pages
|
|
63
|
+
|
|
64
|
+
The same blocks work without the skill.
|
|
65
|
+
|
|
66
|
+
### Three ways to use it
|
|
67
|
+
|
|
68
|
+
| You want | Use | Files |
|
|
69
|
+
| --- | --- | --- |
|
|
70
|
+
| One report file, nothing to host | the **composer** | `node scripts/compose.js page.json report.html` |
|
|
71
|
+
| Charts in your own page, one `<script>` from a CDN | a **kit** | `release/kits/<name>.js` (or `.mjs`) |
|
|
72
|
+
| Fetch only what a page uses, from a CDN or a folder | the **loader** | `release/loader.js` + `core.js` + `blocks/*.js` |
|
|
73
|
+
|
|
74
|
+
#### 1. The composer: JSON in, one HTML file out
|
|
75
|
+
|
|
76
|
+
The composer is a script of this repository (the skill carries a copy), not part of the npm package: run it in a clone.
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
git clone https://github.com/boligolov/blockcharts.git
|
|
80
|
+
cd blockcharts
|
|
81
|
+
npm install
|
|
82
|
+
npm run build && npm run manifest
|
|
83
|
+
node scripts/compose.js skills/blockcharts/recipes/report-from-csv.json report.html
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
`page.json`:
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"title": "Sales",
|
|
91
|
+
"data": { "sales": [ { "region": "North", "total": 42 }, { "region": "South", "total": 58 } ] },
|
|
92
|
+
"charts": [
|
|
93
|
+
{
|
|
94
|
+
"title": "Sales by region",
|
|
95
|
+
"spec": {
|
|
96
|
+
"data": "sales",
|
|
97
|
+
"scales": { "x": { "type": "band" }, "y": { "type": "linear", "zero": true } },
|
|
98
|
+
"guides": [ { "type": "grid", "scale": "y" }, { "type": "axis", "scale": "x" }, { "type": "axis", "scale": "y" } ],
|
|
99
|
+
"marks": [ { "type": "rect", "x": "region", "y": "total" } ],
|
|
100
|
+
"interaction": [ { "type": "tooltip" } ]
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
]
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
The composer works out which blocks the charts need, checks every spec against the data (unknown field, wrong scale type, ... each reported with its path in the JSON), builds each chart once in a sandbox to catch anything that only shows up when drawing, and writes the page. The same input always gives the same bytes. It writes nothing until every chart is valid. Because it has already checked everything, the page carries a lighter core without the checks (`BC.validate`, `BC.needs`), and without the data decoder unless a dataset is stored gzipped: about <!-- build:core-saving -->14 KB<!-- /build --> less per report. The kits for your own pages keep the full core.
|
|
108
|
+
|
|
109
|
+
Datasets can be rows, `{"columns": {...}}`, `{"csv": "text"}`, or `{"csvFile": "orders.csv"}` (next to `page.json`). Large datasets are stored gzipped automatically. For long numeric series from a pipeline, `scripts/encode-columns.js` stores columns as raw typed values (`{"columns": {"t": {"dtype": "float64", "encoding": "gzip+base64", "data": "..."}}}`), never lossy unless you ask for `float32`. Against the gzip a page gets anyway this saves about a third on small integers and a seventh on floats with every digit, and nothing on values rounded to a few decimals; `float32` takes floats to about a third.
|
|
110
|
+
|
|
111
|
+
A dashboard is the same file with a grid: `"layout": {"columns": 4}` and a `span` per chart (KPI tiles `span: 1`, a trend `span: 3`); `title` and `subtitle` head the page. Every chart sits in a card; on a phone the cards stack.
|
|
112
|
+
|
|
113
|
+
Ready-made pages to copy live in `skills/blockcharts/recipes/`, <!-- build:recipes -->48<!-- /build --> of them, among them an executive dashboard (KPI tiles in a grid), waterfall, funnel, bullet, treemap, bar, stacked and grouped bars, dot plot, boxplot, lines with zoom, a slope chart, a moving average and running totals, scatter, a hexbin and density contours of thousands of points, bubbles, dual axis, 100% stacked area, histogram, heatmap, pie, long series, and a CSV report with aggregation and currency formatting.
|
|
114
|
+
|
|
115
|
+
#### 2. Kits: core + blocks in one file
|
|
116
|
+
|
|
117
|
+
```sh
|
|
118
|
+
npm run release # in the clone: writes release/ (the npm package ships the same files)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
```html
|
|
122
|
+
<script src="https://cdn.jsdelivr.net/npm/blockcharts@0.0.1/release/kits/timeseries.js"></script>
|
|
123
|
+
|
|
124
|
+
<script type="application/json" id="bc-data">{ "d": [ { "day": "2024-01-01", "v": 1200 }, { "day": "2024-02-01", "v": 3400 } ] }</script>
|
|
125
|
+
<script type="application/json" data-bc-chart>
|
|
126
|
+
{ "data": "d", "scales": { "x": { "type": "time" }, "y": { "type": "linear", "zero": true } },
|
|
127
|
+
"guides": [ { "type": "axis", "scale": "x" }, { "type": "axis", "scale": "y", "format": "compact" } ],
|
|
128
|
+
"marks": [ { "type": "line", "x": "day", "y": "v" } ] }
|
|
129
|
+
</script>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Charts mount themselves on `DOMContentLoaded`. Or call `BC.chart(element, spec)` yourself and keep the returned handle (`setView`, `getView`, `update`, `destroy`, `ready`).
|
|
133
|
+
|
|
134
|
+
<!-- build:kits -->
|
|
135
|
+
|
|
136
|
+
| Kit | Blocks | Contents | Minified (gzip) |
|
|
137
|
+
|---|---|---|---|
|
|
138
|
+
| `basic` | 19 | Bars, lines, points and areas on linear, log, time and band scales, with axes, grid, legend and tooltip, and fields calculated from the data. | 112 KB (42 KB) |
|
|
139
|
+
| `timeseries` | 29 | Long series over time: lines and areas with zoom, brush, legend filter, decimation, aggregation, wide tables and moving averages; also the canvas renderer for very large series. | 140 KB (51 KB) |
|
|
140
|
+
| `composition` | 33 | Parts of a whole and distributions: stacked bars and areas, pie, heatmap, histogram, boxplot, waterfall, funnel, treemap, aggregation. | 148 KB (54 KB) |
|
|
141
|
+
| `dashboard` | 31 | Business dashboards: KPI tiles with sparklines, bars, lines and areas, waterfall, funnel, treemap, bullet and target lines, donut, with axes, grid, legend, tooltip and legend filter. | 149 KB (55 KB) |
|
|
142
|
+
| `full` | 58 | Every block. | 226 KB (81 KB) |
|
|
143
|
+
|
|
144
|
+
<!-- /build -->
|
|
145
|
+
|
|
146
|
+
Everything in `release/` is minified (esbuild, ES2020) and stripped of the parameter docs, which a running chart never reads; `buildRelease({ minify: false })` keeps the readable code for debugging. Kits are defined in `kits.json`. A kit made for one page contains exactly the blocks that page uses:
|
|
147
|
+
|
|
148
|
+
```sh
|
|
149
|
+
node scripts/build-dist.js --page page.json=report # in the clone: adds release/kits/report.js
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`kits/<name>.mjs` is the same code as an ES module with `export default BC` (browsers load modules over http/https only, not `file://`).
|
|
153
|
+
|
|
154
|
+
#### From npm
|
|
155
|
+
|
|
156
|
+
```sh
|
|
157
|
+
npm install blockcharts
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The package ships the minified files of `release/` (kits, blocks, loader, manifest, types), not the composer or the scripts, and resolves them through `exports`:
|
|
161
|
+
|
|
162
|
+
```js
|
|
163
|
+
import BC from 'blockcharts'; // the full kit, typed
|
|
164
|
+
import BC from 'blockcharts/kits/basic.mjs'; // a smaller kit
|
|
165
|
+
import manifest from 'blockcharts/manifest.json' with { type: 'json' };
|
|
166
|
+
const BC = require('blockcharts'); // CommonJS: the same full kit
|
|
167
|
+
// a <script src> names the file where it is: node_modules/blockcharts/release/kits/timeseries.js (exports are for import/require)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Every kit has a `.d.mts` (and a `.d.ts` for `require`); `blockcharts/bc.d.ts` declares the global `BC` and every spec type. `npm pack` and `npm publish` build the release first (`prepack`).
|
|
171
|
+
|
|
172
|
+
#### 3. The loader: separate files, fetched on demand
|
|
173
|
+
|
|
174
|
+
```html
|
|
175
|
+
<script src="https://cdn.jsdelivr.net/npm/blockcharts@0.0.1/release/loader.js" data-auto></script>
|
|
176
|
+
<!-- your data and <script data-bc-chart> specs -->
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
The loader reads `manifest.json` next to it, loads the core, asks it which blocks the charts on the page need, loads those (and their dependencies), and mounts. Manual control:
|
|
180
|
+
|
|
181
|
+
```js
|
|
182
|
+
await BCLoader.load({
|
|
183
|
+
base: 'https://cdn.jsdelivr.net/npm/blockcharts@0.0.1/release/', // default: the folder of loader.js
|
|
184
|
+
blocks: ['interaction.zoom'], // extra blocks besides the ones found in the page
|
|
185
|
+
scan: true, // find charts on the page (default)
|
|
186
|
+
mount: true, // mount them when loaded (default)
|
|
187
|
+
integrity: true, // put the manifest's SRI hashes on the script tags
|
|
188
|
+
});
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### From a CDN
|
|
192
|
+
|
|
193
|
+
jsDelivr and unpkg serve every file of the npm package on its own, at the path it has in the package:
|
|
194
|
+
`https://cdn.jsdelivr.net/npm/blockcharts@<version>/release/<file>` (or `https://unpkg.com/blockcharts@<version>/release/<file>`),
|
|
195
|
+
where `<file>` is `core.js`, `blocks/<role.type>.js`, `kits/<name>.js` or `.mjs`, `loader.js`, `manifest.json` or `bc.d.ts`.
|
|
196
|
+
The loader takes the core and the blocks from the folder it came from, so it needs nothing more than its own address.
|
|
197
|
+
|
|
198
|
+
#### Pinning with SRI
|
|
199
|
+
|
|
200
|
+
`release/manifest.json` lists a `sha384` hash for every file, ready for the `integrity` attribute:
|
|
201
|
+
|
|
202
|
+
```html
|
|
203
|
+
<script src="https://cdn.jsdelivr.net/npm/blockcharts@0.0.1/release/kits/basic.js" integrity="sha384-..." crossorigin="anonymous"></script>
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Always pin an exact version in the CDN path (`@0.0.1`, not `@0` or `@latest`); files of a version never change.
|
|
207
|
+
|
|
208
|
+
## Spec anatomy
|
|
209
|
+
|
|
210
|
+
```json
|
|
211
|
+
{
|
|
212
|
+
"data": "sales",
|
|
213
|
+
"size": [640, 320],
|
|
214
|
+
"transforms": [ { "type": "aggregate", "groupby": ["region"], "measures": [ { "op": "sum", "field": "total", "as": "sum" } ] } ],
|
|
215
|
+
"scales": { "x": { "type": "band" }, "y": { "type": "linear", "zero": true } },
|
|
216
|
+
"guides": [ { "type": "axis", "scale": "y", "title": "Revenue", "format": { "style": "currency", "currency": "USD" } } ],
|
|
217
|
+
"marks": [ { "type": "rect", "x": "region", "y": "sum" } ],
|
|
218
|
+
"interaction": [ { "type": "tooltip" }, { "type": "zoom" } ]
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Scales are declared once and named. Marks read data through channels (`"x": "region"` means field `region` on the scale named `x`). Guides attach to scales, not marks; several scales per axis direction are fine (dual axis). A block is referred to by its `type`, so `{"type": "rect"}` is `mark.rect`.
|
|
223
|
+
|
|
224
|
+
## Blocks
|
|
225
|
+
|
|
226
|
+
The <!-- build:blocks -->58<!-- /build --> blocks, by role:
|
|
227
|
+
|
|
228
|
+
<!-- build:roles -->
|
|
229
|
+
|
|
230
|
+
| Role | Blocks |
|
|
231
|
+
|---|---|
|
|
232
|
+
| lib | `columns`, `curve`, `pointer`, `stats`, `ticks`, `view` (code other blocks share; a spec never names it) |
|
|
233
|
+
| scale | `band`, `color`, `linear`, `log`, `sequential`, `size`, `time` |
|
|
234
|
+
| transform | `aggregate`, `bin`, `calculate`, `calendar`, `contour`, `decimate`, `density`, `filter`, `fold`, `funnel`, `hexbin`, `highlight`, `marimekko`, `quartiles`, `sankey`, `sort`, `stack`, `treemap`, `waterfall`, `window` |
|
|
235
|
+
| mark | `arc`, `area`, `boxplot`, `candlestick`, `line`, `point`, `polygon`, `rect`, `rule`, `sankey`, `text`, `violin` |
|
|
236
|
+
| guide | `axis`, `grid`, `kpi`, `legend` |
|
|
237
|
+
| interaction | `animate`, `brush`, `crosshair`, `legend-filter`, `tooltip`, `zoom`, `zoom-controls` |
|
|
238
|
+
| renderer | `canvas`, `svg` |
|
|
239
|
+
|
|
240
|
+
<!-- /build -->
|
|
241
|
+
|
|
242
|
+
Every parameter of every block is documented in [`skills/blockcharts/reference/blocks.md`](skills/blockcharts/reference/blocks.md) (generated from the code by `npm run skill`).
|
|
243
|
+
|
|
244
|
+
Custom tooltip content is a function registered in a script with `BC.defineFn(name, fn)` and referenced from the spec by name (`"content": "name"`), so specs stay plain JSON.
|
|
245
|
+
|
|
246
|
+
## Website
|
|
247
|
+
|
|
248
|
+
`site/` is an [Astro](https://astro.build) project: a gallery with every recipe live (its JSON, the composed report, the HTML to embed it), demos of every way to embed (one script tag, the loader, an ES module, the handle API with a custom tooltip, themes, data forms), a guide, and the block reference generated from the code. Every snippet shown is the code that runs above it.
|
|
249
|
+
|
|
250
|
+
```sh
|
|
251
|
+
npm run site # builds the library, the release and the site -> site/dist, then checks links and charts
|
|
252
|
+
SITE_BASE=/blockcharts/ npm run site # for a site served from a subfolder (GitHub Pages)
|
|
253
|
+
npm run dev -w site # develop it (run npm run build and npm run manifest first)
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
The site has its own `package.json` and is an npm workspace of the root: one `npm install` at the root installs both, into one `node_modules`, from one lockfile (Node 22.22.1 or later for the site). The library has no runtime dependencies, nor has the composer; the dev dependencies are the tools that build and test it: TypeScript, esbuild (minifying), fflate (the `.skill` zip, gzip sizes), Prettier and playwright-core (the Chrome checks, with the system Chrome). `scripts/check-site.js` checks the result without a browser: every link, script and anchor resolves, and every chart spec on every page is valid against the data on that page.
|
|
257
|
+
|
|
258
|
+
## Development
|
|
259
|
+
|
|
260
|
+
```sh
|
|
261
|
+
npm install
|
|
262
|
+
npm test # build, manifest, then core/blocks, canvas, composer, CSV, skill and release tests
|
|
263
|
+
npm run test:chrome # layout in a real browser (the system Chrome)
|
|
264
|
+
npm run skill # refresh the skill's generated parts (skills/blockcharts) and the figures this README quotes, write dist/blockcharts.skill
|
|
265
|
+
npm run release # CDN files, kits, loader -> release/ (minified)
|
|
266
|
+
npm run site # the website -> site/dist
|
|
267
|
+
npm run test:site # every page of it in Chrome at phone widths
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
Layout, tests and releasing: [docs/development.md](docs/development.md). What is left to do:
|
|
271
|
+
[ROADMAP.md](ROADMAP.md). Design decisions: [docs/Design.md](docs/Design.md).
|
|
272
|
+
|
|
273
|
+
## Browser support
|
|
274
|
+
|
|
275
|
+
Chrome and Edge 80, Firefox 74, Safari 14.1 or later: the code is ES2020, and compact numbers (`12K`) are `Intl`'s. A
|
|
276
|
+
dataset stored gzipped, which the composer does with a large one, is read with `DecompressionStream`: Firefox 113 and
|
|
277
|
+
Safari 16.4 (Chrome and Edge 80); an older browser shows a message in the chart's place. The composer needs Node 22+.
|
|
278
|
+
|
|
279
|
+
## Versions
|
|
280
|
+
|
|
281
|
+
The skill and the library are versioned apart. The skill's version (`metadata.version` in `SKILL.md`, `version` in
|
|
282
|
+
its `plugin.json`) goes up with every change to `skills/blockcharts/`, the composer and the code it carries included,
|
|
283
|
+
so that Claude Code offers the update. The library's (`package.json`, the path of the CDN files, `BC.version`) goes up
|
|
284
|
+
with a release of the npm package.
|
|
285
|
+
|
|
286
|
+
## License
|
|
287
|
+
|
|
288
|
+
[MIT](LICENSE).
|
package/package.json
CHANGED
|
@@ -1,6 +1,89 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "blockcharts",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Interactive SVG and canvas charts described as JSON, assembled from independent blocks. For standalone HTML reports and for pages of your own.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"charts",
|
|
7
|
+
"visualization",
|
|
8
|
+
"svg",
|
|
9
|
+
"canvas",
|
|
10
|
+
"json",
|
|
11
|
+
"report",
|
|
12
|
+
"dashboard",
|
|
13
|
+
"zoom",
|
|
14
|
+
"no-dependencies"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"author": "Aleksandr Lisin",
|
|
18
|
+
"homepage": "https://blockcharts.online",
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/boligolov/blockcharts.git"
|
|
22
|
+
},
|
|
23
|
+
"bugs": {
|
|
24
|
+
"url": "https://github.com/boligolov/blockcharts/issues"
|
|
25
|
+
},
|
|
26
|
+
"type": "commonjs",
|
|
27
|
+
"main": "./release/kits/full.js",
|
|
28
|
+
"module": "./release/kits/full.mjs",
|
|
29
|
+
"types": "./release/kits/full.d.ts",
|
|
30
|
+
"unpkg": "./release/kits/full.js",
|
|
31
|
+
"jsdelivr": "./release/kits/full.js",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./release/kits/full.d.mts",
|
|
36
|
+
"default": "./release/kits/full.mjs"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./release/kits/full.d.ts",
|
|
40
|
+
"default": "./release/kits/full.js"
|
|
41
|
+
},
|
|
42
|
+
"default": "./release/kits/full.js"
|
|
43
|
+
},
|
|
44
|
+
"./kits/*": "./release/kits/*",
|
|
45
|
+
"./blocks/*": "./release/blocks/*",
|
|
46
|
+
"./core.js": "./release/core.js",
|
|
47
|
+
"./loader.js": "./release/loader.js",
|
|
48
|
+
"./manifest.json": "./release/manifest.json",
|
|
49
|
+
"./bc.d.ts": "./release/bc.d.ts",
|
|
50
|
+
"./package.json": "./package.json"
|
|
51
|
+
},
|
|
52
|
+
"files": [
|
|
53
|
+
"release",
|
|
54
|
+
"LICENSE",
|
|
55
|
+
"README.md"
|
|
56
|
+
],
|
|
57
|
+
"sideEffects": true,
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=22"
|
|
60
|
+
},
|
|
61
|
+
"workspaces": [
|
|
62
|
+
"site"
|
|
63
|
+
],
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsc",
|
|
66
|
+
"manifest": "node scripts/build-manifest.js && node scripts/minify.js",
|
|
67
|
+
"test": "npm run build && npm run manifest && node scripts/test.js && node scripts/test-canvas.js && node scripts/test-compose.js && node scripts/test-csv.js && node scripts/test-skill.js && node scripts/test-dist.js",
|
|
68
|
+
"test:chrome": "npm run build && npm run manifest && node scripts/test-chrome.js",
|
|
69
|
+
"skill": "npm run build && npm run manifest && node scripts/build-skill.js && node scripts/build-docs.js",
|
|
70
|
+
"release": "npm run build && npm run manifest && node scripts/build-dist.js",
|
|
71
|
+
"og": "node scripts/og-image.js",
|
|
72
|
+
"test:site": "node scripts/check-site-phone.js",
|
|
73
|
+
"site": "npm run build && npm run manifest && npm run build -w site && node scripts/check-site.js",
|
|
74
|
+
"prepack": "npm run release",
|
|
75
|
+
"format": "prettier --write \"src/**/*.ts\" \"scripts/**/*.js\" \"site/src/**/*.{mjs,css}\" site/astro.config.mjs",
|
|
76
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"scripts/**/*.js\" \"site/src/**/*.{mjs,css}\" site/astro.config.mjs"
|
|
77
|
+
},
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"esbuild": "^0.28.2",
|
|
80
|
+
"fflate": "^0.8.3",
|
|
81
|
+
"playwright-core": "^1.64.1",
|
|
82
|
+
"prettier": "^3.9.10",
|
|
83
|
+
"typescript": "^7.0.2"
|
|
84
|
+
},
|
|
85
|
+
"allowScripts": {
|
|
86
|
+
"esbuild": true,
|
|
87
|
+
"sharp": false
|
|
88
|
+
}
|
|
89
|
+
}
|