blockcharts alpha

Atomic charts for apps, pages and reports

Only the chart code your page needs. Nothing more.

blockcharts is a chart library cut into atoms: a scale, a bar, an axis, a tooltip — each one a tiny block. A page carries exactly the blocks its charts use, never the whole library. Install it from npm and drop a ready component into React, Vue, Svelte or Angular — or ask Claude for a dashboard as one HTML file.

  • Components for React, Vue, Svelte, Angular
  • Core 12.2 KB gzipped
  • Blocks 0.4–12 KB each
  • Free, MIT license
executive-dashboard.html 24 of 59 blocks 111.9 KB of code

Revenue against plan

Live, from the executive-dashboard recipe — see the whole dashboard. Point at the lines, or tap them.

What is inside executive-dashboard.html

24 of 59 blocks. The other 35 never reach the page.

A chart library is usually one bundle that every page downloads whole. Here every scale, mark, axis and interaction is its own tiny block, and the file carries only the ones its charts name: 111.9 KB of code instead of 215.9 KB.

core29.5 KBdata, layout, the drawing pipeline — always there (the checks run when the page is composed)
lib
columns 0.6 curve 1.2 pointer 1.7 stats 0.4 ticks 0.7 view 0.8
scale
band 1.2 color 0.8 linear 1.6 log 2.1 sequential 2.2 size 1.6 time 4.1
transform
aggregate 5.3 bin 3.3 calculate 1.4 calendar 1.7 contour 5.4 decimate 3.5 density 2.9 filter 2.3 fold 1.5 funnel 1.4 hexbin 4.2 highlight 1.4 marimekko 2.0 quartiles 2.2 sankey 4.1 sort 1.7 stack 2.2 treemap 3.5 waterfall 1.8 window 4.0
mark
arc 4.9 area 2.9 boxplot 2.8 candlestick 2.4 line 4.4 point 3.9 polygon 2.2 rect 4.5 rule 3.8 sankey 6.6 text 5.3 violin 3.0
guide
axis 11.7 grid 0.6 kpi 4.9 legend 6.0
interaction
animate 2.4 brush 3.7 click 1.4 crosshair 2.1 legend-filter 3.0 tooltip 10.7 zoom 2.5 zoom-controls 2.6
renderer
canvas 6.2 svg 3.9

in the file not needed, not shipped sizes in KB, minified

Get started

One package, any framework or none

Ready components for React, Vue and Svelte, a custom element for Angular and any page, and the same charts from plain JavaScript with BC.chart.

npm install blockcharts
  1. Install the packageTyped for TypeScript, no dependencies; React, Vue and Svelte are optional peers.
  2. Import a kit onceblockcharts/kits/basic.mjs for bars, lines and areas, or another kit: the only chart code your app carries.
  3. Drop in a componentGive it a JSON spec and your rows, or call BC.chart(element, spec) yourself. A click on a bar comes back to your code with its row; on a server a component renders an empty element and draws in the browser.
import 'blockcharts/kits/basic.mjs'; // once, before a chart mounts
import { useRef } from 'react';
import { BlockChart } from 'blockcharts/react';

const spec = {
  scales: { x: { type: 'band' }, y: { type: 'linear', zero: true } },
  guides: [
    { type: 'axis', scale: 'x' },
    { type: 'axis', scale: 'y', format: 'compact' },
  ],
  marks: [{ type: 'rect', x: 'region', y: 'total' }],
  interaction: [{ type: 'tooltip' }],
};

export function Regions({ rows, onPick }) {
  const chart = useRef(null); // chart.current.setView('x', null)
  return (
    <BlockChart
      ref={chart}
      spec={spec}
      data={rows}
      onClick={(d) => onPick(d.values.region)}
    />
  );
}

The Claude skill

From a spreadsheet to a report in one request

No app to write: install the skill once, then give Claude the data and say what you want to see.

  1. Your dataPaste a table into the chat or point to a CSV file. Dirty exports are fine: totals per month or per region are computed in the page.
  2. Claude describes the chartsAs a short JSON description, never as code. The composer checks every chart against the real data and names each mistake, so Claude fixes it before you see anything.
  3. You get one HTML fileInteractive charts with tooltips, zoom and a clickable legend. Email it, attach it to a ticket, put it in a shared folder — it opens anywhere, offline.

Download the skill and upload it under Settings → Capabilities → Skills. Code execution must be on: Claude runs the composer in its sandbox and hands you the HTML file.

Download blockcharts.skill

Then just ask: “make an HTML report of monthly revenue by region from sales.csv”. More on scopes and updates in docs/skill.md.

How it works

Charts described as data, built from blocks

There is no chart code to get wrong. A chart is a few lines of JSON; the page is assembled from exactly the blocks those lines name.

1 · Describe

A chart is a JSON spec

Data, named scales, marks, axes and interactions. The same description a person or an agent can read.

{
  "data": "orders",
  "scales": {"x": {"type": "band"}, "y": {"type": "linear"}},
  "marks": [{"type": "rect", "x": "region", "y": "revenue"}],
  "interaction": [{"type": "tooltip"}]
}
2 · Check

Validated against the data

Unknown columns, wrong scale types, broken formats — reported with their place in the JSON. Nothing is written while a chart is wrong.

charts[1].marks[0].y:
  unknown field "revnue" in dataset "orders"
3 · Assemble

Only the blocks it names

The spec of step 1 needs 7 blocks: lib.pointer, lib.ticks, scale.band, scale.linear, mark.rect, interaction.tooltip, renderer.svg. Only those, the core and the data go into the file.

sales-report.html
  core + 7 blocks + data
  opens from disk, offline

In numbers

A report carries its charts, not a whole library

Minified sizes of the code inside each composed page of the examples, next to everything blockcharts has. The data comes on top, gzipped when it is large.

59
blocks, one job each
12KB
the core of a report, gzipped (29.5 KB minified)
51KB
code in the lightest example report (Gauge and progress ring)
0
dependencies, and no network requests from a report
A pie chart · 7 blocks 60.5 KB
A bar chart with labels · 10 blocks 71.3 KB
A sales report from CSV · 15 blocks 90.2 KB
An executive dashboard, 8 charts · 24 blocks 111.9 KB
Everything · 59 blocks 215.9 KB

Customizable

Change anything, from a color to a whole new block

Atoms compose in any way you need. Nothing to fork, no plugin system to learn: the built-in blocks use the same contract you do.

  1. 1
    Parameters

    Each block documents its own: currency and date formats in any locale, axis titles, bar radius, tooltip fields, zoom limits. Every parameter →

  2. 2
    CSS

    Colors are CSS variables and shapes have classes. A brand palette, dark mode or a print style is a stylesheet, not a spec change. Themes →

  3. 3
    Your set of blocks

    Build a kit with exactly the blocks you draw — bars and a tooltip, nothing else — or let the loader fetch them per page. Kits and the loader →

  4. 4
    Functions by name

    A tooltip with your own content is a function registered once with BC.defineFn and named from the spec, so specs stay JSON. The handle API →

  5. 5
    Blocks of your own

    A block is a small script calling BC.define — the same contract as the built-in ones. Validated, themed, and shipped only where it is used. Write a block →

A new block: a target line

BC.define({
  role: 'guide', type: 'target', version: 1,
  params: { scale: { kind: 'scale', required: true },
            value: { kind: 'number', required: true } },
  render(spec, ctx) {
    const y = ctx.scales[spec.scale](spec.value), { x, w } = ctx.plot;
    return { overlay: [{ type: 'path', d: `M${x} ${y}H${x + w}`,
      style: { stroke: 'var(--bc-c2)', strokeDash: [5, 4] } }] };
  },
});

Used in a spec

{ "type": "target", "scale": "y", "value": 50000 }

Your colors

.report {
  --bc-c0: #0b5cad;  /* your brand blue */
  --bc-text: #33415c;
  --bc-grid: #e8edf5;
}

The principles

Atoms first: why a report stays small

blockcharts principles v1.1 — how a page gets exactly the code its charts need and what follows from it, written down for a person writing a report, an agent writing one for them, and anyone writing a block. With the requirements every page, block and composer must meet.

§1

Exactly what the charts need, nothing more

A page carries the core and only the blocks its charts use. They are read from the specs and their declared dependencies — never listed by hand, so the list is never too long.

§2

Blocks are atoms

One role, one job: scales, transforms, marks, guides, interactions, renderers. A bar chart is band + linear + rect; a new kind of chart is a recipe, or one new block.

§3

Customizable at every level

Parameters, CSS variables and classes, your own set of blocks, functions by name, and blocks of your own on the same contract as the built-in ones.

§4

The page is the product

A report is one HTML file. It opens from disk, works offline, needs no server or account — everything it needs is inside it, and nothing it does not.

§5–7

The chart is data, checked

Plain JSON, everything declared once. Every chart is validated against the real data before the file is written; each problem names its place in the JSON.

§8–10

Light, repeatable, private

Big data is gzipped or binary, long series decimated. The same input gives the same bytes. A report loads nothing from the network.

For the people who read the report

A dashboard your team can just open

No BI seat to buy, no link that stops working, no deck of static screenshots.

Opens anywhere

One .html file: double-click it, email it, attach it to a ticket, keep it next to the data. No server, no login, no internet needed.

Interactive, not a screenshot

Tooltips with formatted numbers, zoom and pan on time series, drag to select, click the legend to hide a series and watch the rest rescale.

Numbers you can trust

Every chart is checked against the data before the file exists. Money, percentages and dates are formatted the same way on every machine.

Fast with real data

A year of hourly readings or tens of thousands of points stays smooth: long lines are thinned to what the screen can show, big scatters drawn on a canvas.

Looks like your company

Charts take their colors and fonts from CSS variables: your palette, light and dark themes, clean printing — without touching a chart.

Your data stays yours

The composer runs on your machine or in Claude’s sandbox. The report fetches nothing and reports nothing: no scripts from elsewhere, no analytics, no tracking.

Four ways in

One set of blocks, however you ship it

In an app, install from npm and use a component. In a page of your own, one script tag. For a report file to send around, the agent skill — pick by where the charts will live.

One script tag

For your own pages

A kit is the core and a set of blocks in one file, from npm, a CDN or your own site — 42.9 KB gzipped for bars, lines and areas. Charts are JSON in the HTML.

npm install blockcharts
Try a kit →

Loader

For sites with many different charts

A 2.0 KB script finds the charts on a page and fetches only the blocks they use, with SRI hashes from the release manifest.

<script src=".../0.0.5/loader.js" data-auto></script>
Try the loader →

Agent skill

For report files, from a table

Claude writes the JSON, the bundled composer checks it against the data and writes one HTML file that opens anywhere. The same composer runs from a script or CI.

make a report of revenue by region from sales.csv
Get the skill →

Your next dashboard, with nothing extra in it

Install blockcharts from npm, drop a component into your app, and ship only the chart code it uses. For a report file, the Claude skill does it from a table.