New in 0.11
Embed in any page
Try it
A plain HTML page with no framework, in a sandboxed frame: three <silverpoint-chart> elements, each holding a JSON spec, and the standalone file silverpoint-embed.full.js (0.11.2) served by this site. Hover or focus a chart and move with the arrow keys: the readout below the charts listens to the bubbling sp-activechange event. Open the page on its own.
Embed or adapter?
Use an adapter when your app is React, Vue, Angular or Reflex. Use @silverpoint/embed for a plain page, a server, a workflow node, a BI tool, a notebook or a CMS. It is the same engine as the adapters, so the same picture, keyboard reading and precision mode; the MCP server's render_chart renders through it.
npm install @silverpoint/embed
# the standalone files are in node_modules/@silverpoint/embed/dist/:
cp node_modules/@silverpoint/embed/dist/silverpoint-embed.full.js public/vendor/
cp node_modules/@silverpoint/embed/dist/integrity.json public/vendor/A chart is a spec
One JSON object draws any of the 60 charts. Only chart is required. validateSpec says why a spec cannot render: bad JSON, a field the spec does not have, an unknown chart (with the closest slugs), an undeclared prop, a size out of range, or a spec over 2 MB (SP030).
{ "chart": "bar-chart",
"data": [{ "team": "A", "wins": 12 }, { "team": "B", "wins": 9 }],
"props": { "xKey": "team", "valueKey": "wins", "title": "Wins" },
"width": 480, "ground": "silverpoint", "substrate": "cream", "mode": "ink", "palette": "sepia" }| Field | Type | |
|---|---|---|
chart | string, required | The chart's slug: one of the 60 (bar-chart, donut-chart…). |
data | array | The rows; without it the chart draws its demo data. |
props | object | The chart's own props and the common view props (title, badge, dataTable, seed, hatchFill…). |
width / height | number | 160..1600 × 90..1200. |
ground / substrate | string | silverpoint (cream, green, blue, ochre) or cyanotype (prussian). |
mode | 'ink' | 'precision' | Ink by default. |
palette | string | object | A preset name (sepia…) or a palette object. |
In a page: one file, one element
The script defines <silverpoint-chart> and mounts every [data-sp-embed] box once the page is parsed. It opens no connection, evaluates no string and writes no storage, so it runs under script-src 'self'; style-src 'self' and in a sandbox="allow-scripts" frame, as on this page. Serve the file yourself and pin it with integrity.json (SHA-384 per file); no CDN is involved.
<script src="/vendor/silverpoint-embed.full.js"
integrity="sha384-zgW8GWU5rRz2azBQ5sBHTNrLG4I2PlQ8p9x4cb65/lXDKQ8no5bdhqkKGMftCkjX"
crossorigin="anonymous"></script>
<silverpoint-chart>
<script type="application/json">
{ "chart": "donut-chart", "props": { "title": "Budget" } }
</script>
</silverpoint-chart>
<!-- or a box the script mounts once the page is parsed -->
<div data-sp-embed>
<script type="application/json">{ "chart": "line-chart", "width": 480 }</script>
</div>| File | What | gzip budget |
|---|---|---|
silverpoint-embed.js / .mjs | The script (global Silverpoint) / the ES module | 140 kB |
silverpoint-embed.full.js / .full.mjs | The same with EB Garamond's three cuts inlined | 220 kB |
SP031; nothing throws in the page.The client API
For pages that drive the chart: mount(target, spec, options) returns a handle with update, destroy, getGeometry and toSVGString. onActiveChange, onSelect and onDiagnostic, and the bubbling sp-activechange, sp-select and sp-diagnostic events, report what the reader does. hostAppearance picks the ground, substrate and mode that suit a host's own background.
import { mount, hostAppearance } from '@silverpoint/embed/client';
const chart = mount(document.querySelector('#hits'), {
chart: 'line-chart',
data: rows,
props: { xKey: 'hour', valueKey: 'hits', title: 'Hits per hour' },
}, {
// the host's theme, under the spec's own fields
appearance: hostAppearance({ background: '#0b2a4a' }),
onActiveChange: (item) => console.log(item?.datum, item?.value),
onSelect: (item) => console.log('selected', item.datum),
});
chart.update({ chart: 'line-chart', data: newRows });
const svg = chart.toSVGString({ standalone: true }); // the ground's stylesheet inside
chart.destroy();
// or listen to the bubbling events of every chart on the page
document.addEventListener('sp-activechange', (event) => console.log(event.detail));On a server or in a flow
renderToSVG and renderToHTML run in Node with no DOM, byte for byte the same for the same spec. renderToHTML writes the accessible chart root, complete with no script, and with interactive the spec as JSON for a client on the page to adopt.
import { renderToHTML, renderToSVG, validateSpec } from '@silverpoint/embed';
const checked = validateSpec(input); // why a spec cannot render, before rendering it
if (!checked.ok) throw new Error(checked.error.message);
const svg = renderToSVG({ chart: 'line-chart', props: { title: 'Hits' } });
if (svg.ok) writeFileSync('hits.svg', svg.value.svg); // the MCP server's render_chart
// a whole document, complete with no script; `interactive` adds the spec for a client to adopt
const page = renderToHTML({ chart: 'line-chart' }, { as: 'document' });From a table: the host catalog
host-catalog.json describes every chart a table can feed (its roles, dimension, measure and temporal, its options and the appearance values), so a BI tool's property pane is generated, never typed by hand. specFromTable binds; it does not aggregate, sort or filter. Four charts are not fed from a table (orbit, sparkline rows, volvelle and the grid treemap): their entries say why.
import { HOST_CATALOG, specFromTable } from '@silverpoint/embed/hosts';
const spec = specFromTable({
chart: 'heatmap-chart',
table: { rows: [{ day: 'Mon', hour: '09', load: 12 }, { day: 'Mon', hour: '10', load: 34 }] },
roles: { row: 'day', column: 'hour', value: 'load' },
});The host integrations the agent catalog 0.11.2 lists, each in a repository of its own (Flask, Django, Jupyter and Databricks are inside the Python package):
| Host | Code | Kind | Through | Package | Status | |
|---|---|---|---|---|---|---|
| Power BI | repository | bi | embed | silverpoint-powerbi | released | A custom visual: fields on roles, any of the tabular charts. |
| Tableau | repository | bi | embed | silverpoint-tableau | released | Viz extensions, one manifest per chart, drawing on a worksheet. |
| KNIME | repository | workflow | python | silverpoint-knime | released | View nodes that draw a chart from a table, through the Python package. |
| n8n | repository | workflow | embed | n8n-nodes-silverpoint | released | A community node that draws a chart from workflow items, as SVG or HTML. |
| Apache Superset | repository | bi | react | superset-plugin-chart-silverpoint | released | Visualization plugins, one per chart, drawn by the React adapter. |
| Plone Volto | repository | cms | react | volto-silverpoint | released | A block that draws a chart from a table, server-rendered and hydrated. |
| Plone Classic UI | repository | cms | python | collective.silverpoint | released | A Chart content type and a view for templates, through the Python package. |
| Python | repository | language | embed | silverpoint | released | A chart from a DataFrame as self-contained HTML; the standalone file vendored. |
| Flask | in silverpoint | web | python | silverpoint[flask] | released | Jinja globals and a route for the script, inside the Python package. |
| Django | in silverpoint | web | python | silverpoint[django] | released | An installable app with template tags, inside the Python package. |
| Jupyter | in silverpoint | notebook | python | silverpoint | released | A chart as a cell output, in a sandboxed frame. |
| Databricks notebooks | in silverpoint | notebook | python | silverpoint | released | A chart in a notebook cell with displayHTML; AI/BI dashboards are out (DD-072). |
Proving a host draws correctly
Run the conformance kit against the file you ship, in the runtime you ship it in: one case per chart plus the appearance axes on four charts, SHA-256 per render.
import { conformance } from '@silverpoint/embed/conformance';
import { renderToSVG } from '@silverpoint/embed';
const { passed, failed } = await conformance((spec) => {
const result = renderToSVG(spec);
return result.ok ? result.value.svg : '';
});Embedding and agents
The MCP server writes the page for you: generate_code with framework: "html" returns the <script> with its integrity and a <silverpoint-chart>; search_catalog finds the host integrations, and the silverpoint skill carries references/hosts.md. Use with AI →
{ "name": "generate_code",
"arguments": { "target": { "chart": "donut-chart" }, "framework": "html" } }