blockcharts 0.0.0-stage → 0.0.2
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 +289 -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,290 @@
|
|
|
1
|
-
#
|
|
1
|
+
# blockcharts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/blockcharts)
|
|
4
|
+
[](https://github.com/boligolov/blockcharts/actions/workflows/ci.yml)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
**Atomic charts for HTML dashboards: a page carries only the chart code it needs. Nothing more.**
|
|
8
|
+
|
|
9
|
+
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 -->.
|
|
10
|
+
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.
|
|
11
|
+
Charts are described in JSON, drawn in SVG or on a canvas, and every part can be customized, down to blocks of your own.
|
|
12
|
+
|
|
13
|
+
**[Website](https://blockcharts.online)** · **[Gallery](https://blockcharts.online/examples/)** · **[Guide](https://blockcharts.online/guide/)** · **[Blocks](https://blockcharts.online/blocks/)** · [Principles](docs/spec/principles.md)
|
|
14
|
+
|
|
15
|
+
[](https://blockcharts.online/examples/executive-dashboard/)
|
|
16
|
+
|
|
17
|
+
*KPI tiles, a trend against plan, a donut, a waterfall and a funnel: one standalone HTML file,
|
|
18
|
+
[live in the gallery](https://blockcharts.online/examples/executive-dashboard/).*
|
|
19
|
+
|
|
20
|
+
## Quick start
|
|
21
|
+
|
|
22
|
+
One script tag, and a chart described in JSON where it should appear:
|
|
23
|
+
|
|
24
|
+
```html
|
|
25
|
+
<script src="https://cdn.jsdelivr.net/npm/blockcharts@0.0.2/release/kits/basic.js"></script>
|
|
26
|
+
|
|
27
|
+
<script type="application/json" id="bc-data">
|
|
28
|
+
{ "sales": [ { "region": "North", "total": 42 }, { "region": "South", "total": 58 }, { "region": "East", "total": 31 } ] }
|
|
29
|
+
</script>
|
|
30
|
+
<script type="application/json" data-bc-chart>
|
|
31
|
+
{ "data": "sales",
|
|
32
|
+
"scales": { "x": { "type": "band" }, "y": { "type": "linear", "zero": true } },
|
|
33
|
+
"guides": [ { "type": "axis", "scale": "x" }, { "type": "axis", "scale": "y" } ],
|
|
34
|
+
"marks": [ { "type": "rect", "x": "region", "y": "total" } ],
|
|
35
|
+
"interaction": [ { "type": "tooltip" } ] }
|
|
36
|
+
</script>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Charts draw themselves when the page loads. With a bundler or a framework:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
npm install blockcharts
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
import BC from 'blockcharts';
|
|
47
|
+
|
|
48
|
+
BC.data('sales', rows);
|
|
49
|
+
const chart = BC.chart(document.getElementById('chart'), spec); // update, setView, getView, destroy, ready
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Why blockcharts
|
|
53
|
+
|
|
54
|
+
- **Only the code your charts use.** The blocks a page needs are read from its specs and closed over their
|
|
55
|
+
dependencies: a bar chart with labels and a tooltip carries <!-- build:bar -->10 of the 58 blocks, 71 KB of code instead of 214<!-- /build -->; a whole
|
|
56
|
+
executive dashboard (KPI tiles, a trend, a donut, a waterfall, a funnel, animated) carries <!-- build:dashboard-blocks -->24<!-- /build -->. Nobody lists
|
|
57
|
+
blocks by hand, so the list is never too long.
|
|
58
|
+
- **Charts are data, checked before they are drawn.** A chart is a plain JSON spec, not code. It is checked against
|
|
59
|
+
the real data, and every mistake comes back with its place in the JSON.
|
|
60
|
+
- **One file that opens anywhere.** The composer turns JSON and data into a single HTML report that opens from disk,
|
|
61
|
+
offline, can be emailed or printed, and loads nothing from the network. The same input always gives the same bytes.
|
|
62
|
+
- **Customizable at every level.** Block parameters (formats, locales, axes, tooltips), CSS variables and classes
|
|
63
|
+
(brand colors, dark mode, print), your own set of blocks, functions by name (`BC.defineFn`), and blocks of your
|
|
64
|
+
own — a small script calling `BC.define`, the same contract the built-in blocks use
|
|
65
|
+
([an example](https://blockcharts.online/embed/block/)).
|
|
66
|
+
- **Heavy data stays light.** A canvas renderer for tens of thousands of points, decimation, aggregation, and large
|
|
67
|
+
datasets stored gzipped in the page.
|
|
68
|
+
- **No dependencies.** Plain ES2020 in every modern browser, typed for TypeScript, MIT-licensed.
|
|
69
|
+
|
|
70
|
+
What it is built on: [the blockcharts principles](docs/spec/principles.md), v<!-- build:principles-version -->1.1<!-- /build -->.
|
|
71
|
+
|
|
72
|
+
## What it draws
|
|
73
|
+
|
|
74
|
+
Bars (stacked, grouped, 100%), lines and areas, scatter and bubbles, hexbins and density contours, pie and donut,
|
|
75
|
+
heatmaps and calendars, histograms, boxplots and violins, waterfalls, funnels, treemaps, sankey and marimekko
|
|
76
|
+
diagrams, candlesticks, KPI tiles with sparklines, bullet and target lines — with tooltips, a crosshair, zoom and
|
|
77
|
+
brush, legend filters and animation.
|
|
78
|
+
|
|
79
|
+
Every kind is live in the [gallery](https://blockcharts.online/examples/), with its JSON and the HTML to embed it. The
|
|
80
|
+
<!-- build:recipes -->48<!-- /build --> ready-made pages behind it are in [`skills/blockcharts/recipes/`](skills/blockcharts/recipes/), to copy.
|
|
81
|
+
|
|
82
|
+
## Ways to ship it
|
|
83
|
+
|
|
84
|
+
| You want | Use |
|
|
85
|
+
| --- | --- |
|
|
86
|
+
| Charts in your own page, one `<script>` | a **kit**: the core and a set of blocks in one file |
|
|
87
|
+
| Each page to fetch only what it uses | the **loader**: `loader.js`, the core and single block files |
|
|
88
|
+
| A bundler or a framework component | the **npm package**: `import BC from 'blockcharts'` |
|
|
89
|
+
| One report file, nothing to host | the **composer**: JSON and data in, one HTML file out |
|
|
90
|
+
|
|
91
|
+
### Kits
|
|
92
|
+
|
|
93
|
+
A kit is the core and a set of blocks in one file: a classic script (`kits/<name>.js`) or an ES module
|
|
94
|
+
(`kits/<name>.mjs`, `export default BC`; browsers load modules over http and https only, not from `file://`).
|
|
95
|
+
|
|
96
|
+
<!-- build:kits -->
|
|
97
|
+
|
|
98
|
+
| Kit | Blocks | Contents | Minified (gzip) |
|
|
99
|
+
|---|---|---|---|
|
|
100
|
+
| `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) |
|
|
101
|
+
| `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. | 141 KB (52 KB) |
|
|
102
|
+
| `composition` | 33 | Parts of a whole and distributions: stacked bars and areas, pie, heatmap, histogram, boxplot, waterfall, funnel, treemap, aggregation. | 149 KB (54 KB) |
|
|
103
|
+
| `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) |
|
|
104
|
+
| `full` | 58 | Every block. | 226 KB (81 KB) |
|
|
105
|
+
|
|
106
|
+
<!-- /build -->
|
|
107
|
+
|
|
108
|
+
Everything is minified (esbuild, ES2020) and stripped of the parameter docs, which a running chart never reads.
|
|
109
|
+
Charts mount themselves on `DOMContentLoaded`; or call `BC.chart(element, spec)` and keep the handle.
|
|
110
|
+
|
|
111
|
+
### The loader
|
|
112
|
+
|
|
113
|
+
```html
|
|
114
|
+
<script src="https://cdn.jsdelivr.net/npm/blockcharts@0.0.2/release/loader.js" data-auto></script>
|
|
115
|
+
<!-- your data and <script data-bc-chart> specs -->
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The loader reads `manifest.json` next to it, loads the core, asks it which blocks the charts on the page need, loads
|
|
119
|
+
only those (with their dependencies) and draws. By hand:
|
|
120
|
+
|
|
121
|
+
```js
|
|
122
|
+
await BCLoader.load({
|
|
123
|
+
base: 'https://cdn.jsdelivr.net/npm/blockcharts@0.0.2/release/', // default: the folder of loader.js
|
|
124
|
+
blocks: ['interaction.zoom'], // extra blocks besides the ones found in the page
|
|
125
|
+
scan: true, // find charts on the page (default)
|
|
126
|
+
mount: true, // draw them when loaded (default)
|
|
127
|
+
integrity: true, // put the manifest's SRI hashes on the script tags
|
|
128
|
+
});
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### npm
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
npm install blockcharts
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
```js
|
|
138
|
+
import BC from 'blockcharts'; // the full kit, typed
|
|
139
|
+
import BC from 'blockcharts/kits/basic.mjs'; // a smaller kit
|
|
140
|
+
import manifest from 'blockcharts/manifest.json' with { type: 'json' };
|
|
141
|
+
const BC = require('blockcharts'); // CommonJS: the same full kit
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
The package carries the built files: kits, single blocks, the loader, the manifest and the types. Every kit has a
|
|
145
|
+
`.d.mts` (and a `.d.ts` for `require`); `blockcharts/bc.d.ts` declares the global `BC` and every spec type. A
|
|
146
|
+
`<script src>` names the file where it is: `node_modules/blockcharts/release/kits/basic.js`.
|
|
147
|
+
|
|
148
|
+
### CDN and integrity
|
|
149
|
+
|
|
150
|
+
jsDelivr and unpkg serve every file of the package at its path in it:
|
|
151
|
+
`https://cdn.jsdelivr.net/npm/blockcharts@<version>/release/<file>` (or `https://unpkg.com/blockcharts@<version>/release/<file>`),
|
|
152
|
+
where `<file>` is `core.js`, `blocks/<role.type>.js`, `kits/<name>.js` or `.mjs`, `loader.js`, `manifest.json` or
|
|
153
|
+
`bc.d.ts`. Pin an exact version (`@0.0.2`, not `@0` or `@latest`): files of a version never change, and
|
|
154
|
+
`manifest.json` lists a `sha384` hash of every file for the `integrity` attribute:
|
|
155
|
+
|
|
156
|
+
```html
|
|
157
|
+
<script src="https://cdn.jsdelivr.net/npm/blockcharts@0.0.2/release/kits/basic.js" integrity="sha384-..." crossorigin="anonymous"></script>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### The composer: one standalone report
|
|
161
|
+
|
|
162
|
+
The composer is a script of this repository, not part of the npm package: run it in a clone.
|
|
163
|
+
|
|
164
|
+
```sh
|
|
165
|
+
git clone https://github.com/boligolov/blockcharts.git
|
|
166
|
+
cd blockcharts
|
|
167
|
+
npm install
|
|
168
|
+
npm run build && npm run manifest
|
|
169
|
+
node scripts/compose.js skills/blockcharts/recipes/report-from-csv.json report.html
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
`page.json`:
|
|
173
|
+
|
|
174
|
+
```json
|
|
175
|
+
{
|
|
176
|
+
"title": "Sales",
|
|
177
|
+
"data": { "sales": [ { "region": "North", "total": 42 }, { "region": "South", "total": 58 } ] },
|
|
178
|
+
"charts": [
|
|
179
|
+
{
|
|
180
|
+
"title": "Sales by region",
|
|
181
|
+
"spec": {
|
|
182
|
+
"data": "sales",
|
|
183
|
+
"scales": { "x": { "type": "band" }, "y": { "type": "linear", "zero": true } },
|
|
184
|
+
"guides": [ { "type": "grid", "scale": "y" }, { "type": "axis", "scale": "x" }, { "type": "axis", "scale": "y" } ],
|
|
185
|
+
"marks": [ { "type": "rect", "x": "region", "y": "total" } ],
|
|
186
|
+
"interaction": [ { "type": "tooltip" } ]
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
The composer works out which blocks the charts need, checks every spec against the data (an unknown field, a wrong
|
|
194
|
+
scale type, … each reported with its path in the JSON), draws each chart once in a sandbox to catch what only shows
|
|
195
|
+
up when drawing, and writes the page; nothing is written until every chart is valid. Having checked everything, the
|
|
196
|
+
page carries a lighter core, without the checks and, unless a dataset is stored gzipped, without the data decoder:
|
|
197
|
+
about <!-- build:core-saving -->14 KB<!-- /build --> less per report.
|
|
198
|
+
|
|
199
|
+
Datasets can be rows, `{"columns": {...}}`, `{"csv": "text"}`, or `{"csvFile": "orders.csv"}` (next to `page.json`);
|
|
200
|
+
large ones are stored gzipped automatically. A dashboard is the same file with a grid: `"layout": {"columns": 4}` and
|
|
201
|
+
a `span` per chart (KPI tiles `span: 1`, a trend `span: 3`), with a `title` and a `subtitle` on top. Every chart sits
|
|
202
|
+
in a card, and on a phone the cards stack.
|
|
203
|
+
|
|
204
|
+
## How a chart is described
|
|
205
|
+
|
|
206
|
+
```json
|
|
207
|
+
{
|
|
208
|
+
"data": "sales",
|
|
209
|
+
"size": [640, 320],
|
|
210
|
+
"transforms": [ { "type": "aggregate", "groupby": ["region"], "measures": [ { "op": "sum", "field": "total", "as": "sum" } ] } ],
|
|
211
|
+
"scales": { "x": { "type": "band" }, "y": { "type": "linear", "zero": true } },
|
|
212
|
+
"guides": [ { "type": "axis", "scale": "y", "title": "Revenue", "format": { "style": "currency", "currency": "USD" } } ],
|
|
213
|
+
"marks": [ { "type": "rect", "x": "region", "y": "sum" } ],
|
|
214
|
+
"interaction": [ { "type": "tooltip" }, { "type": "zoom" } ]
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Scales are declared once and named. Marks read data through channels (`"x": "region"` means the field `region` on
|
|
219
|
+
the scale named `x`). Guides attach to scales, not to marks, and several scales per direction are fine (a dual axis).
|
|
220
|
+
A block is named by its `type`, so `{"type": "rect"}` is `mark.rect`. Custom tooltip content is a function registered
|
|
221
|
+
with `BC.defineFn(name, fn)` and named in the spec (`"content": "name"`), so specs stay plain JSON.
|
|
222
|
+
|
|
223
|
+
## Blocks
|
|
224
|
+
|
|
225
|
+
The <!-- build:blocks -->58<!-- /build --> blocks, by role:
|
|
226
|
+
|
|
227
|
+
<!-- build:roles -->
|
|
228
|
+
|
|
229
|
+
| Role | Blocks |
|
|
230
|
+
|---|---|
|
|
231
|
+
| lib | `columns`, `curve`, `pointer`, `stats`, `ticks`, `view` (code other blocks share; a spec never names it) |
|
|
232
|
+
| scale | `band`, `color`, `linear`, `log`, `sequential`, `size`, `time` |
|
|
233
|
+
| transform | `aggregate`, `bin`, `calculate`, `calendar`, `contour`, `decimate`, `density`, `filter`, `fold`, `funnel`, `hexbin`, `highlight`, `marimekko`, `quartiles`, `sankey`, `sort`, `stack`, `treemap`, `waterfall`, `window` |
|
|
234
|
+
| mark | `arc`, `area`, `boxplot`, `candlestick`, `line`, `point`, `polygon`, `rect`, `rule`, `sankey`, `text`, `violin` |
|
|
235
|
+
| guide | `axis`, `grid`, `kpi`, `legend` |
|
|
236
|
+
| interaction | `animate`, `brush`, `crosshair`, `legend-filter`, `tooltip`, `zoom`, `zoom-controls` |
|
|
237
|
+
| renderer | `canvas`, `svg` |
|
|
238
|
+
|
|
239
|
+
<!-- /build -->
|
|
240
|
+
|
|
241
|
+
Every parameter of every block: [the block reference](https://blockcharts.online/blocks/), also in
|
|
242
|
+
[`skills/blockcharts/reference/blocks.md`](skills/blockcharts/reference/blocks.md).
|
|
243
|
+
|
|
244
|
+
## Browser support
|
|
245
|
+
|
|
246
|
+
Chrome and Edge 80, Firefox 74, Safari 14.1 or later: the code is ES2020, and compact numbers (`12K`) are `Intl`'s. A
|
|
247
|
+
dataset stored gzipped, which the composer does with a large one, is read with `DecompressionStream`: Firefox 113 and
|
|
248
|
+
Safari 16.4 (Chrome and Edge 80); an older browser shows a message in the chart's place. The composer needs Node 22+.
|
|
249
|
+
|
|
250
|
+
## Development
|
|
251
|
+
|
|
252
|
+
```sh
|
|
253
|
+
npm install
|
|
254
|
+
npm test # build, then the core, blocks, canvas, composer, CSV, skill and release tests
|
|
255
|
+
npm run test:chrome # layout in a real browser (the system Chrome)
|
|
256
|
+
npm run release # kits, single blocks and the loader -> release/
|
|
257
|
+
npm run skill # the skill's generated parts and the figures this README quotes
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Layout, tests, the website and releasing: [docs/development.md](docs/development.md). What is left to do:
|
|
261
|
+
[ROADMAP.md](ROADMAP.md). Design decisions: [docs/Design.md](docs/Design.md).
|
|
262
|
+
|
|
263
|
+
## For AI agents: the blockcharts skill
|
|
264
|
+
|
|
265
|
+
An agent skill turns a table or a CSV file into one light `.html` report with interactive charts. The agent writes
|
|
266
|
+
only the JSON; the composer bundled with the skill checks every chart against the data and writes the page.
|
|
267
|
+
|
|
268
|
+
**Claude Code** — from this repository, which is a plugin marketplace:
|
|
269
|
+
|
|
270
|
+
```
|
|
271
|
+
/plugin marketplace add boligolov/blockcharts
|
|
272
|
+
/plugin install blockcharts@blockcharts
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
It updates by itself once auto-update is on for the marketplace (`/plugin` → *Marketplaces*), or by hand with
|
|
276
|
+
`claude plugin update blockcharts@blockcharts`.
|
|
277
|
+
|
|
278
|
+
**Claude.ai and Claude Desktop** — download **[blockcharts.skill](https://blockcharts.online/blockcharts.skill)**
|
|
279
|
+
and upload it under *Settings → Capabilities → Skills* (skills need code execution enabled).
|
|
280
|
+
|
|
281
|
+
**Any other agent that reads skill folders** — copy [`skills/blockcharts/`](skills/blockcharts/) into its skills
|
|
282
|
+
folder (`~/.claude/skills/` for Claude Code). It needs Node.js 22+.
|
|
283
|
+
|
|
284
|
+
Then ask — *"an HTML report of monthly revenue by region from sales.csv"*, *"a dashboard of these KPIs"*. Scopes and
|
|
285
|
+
details: [docs/skill.md](docs/skill.md). The skill is versioned apart from the library (`metadata.version` in
|
|
286
|
+
`SKILL.md`, `version` in its `plugin.json`), so that Claude Code offers each update.
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
[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.2",
|
|
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
|
+
}
|