Skip to content
silverpoint
Documentation menu

New in 0.11

Embed in any page

New in silverpoint 0.11. @silverpoint/embed draws any of the 60 charts from one JSON spec, outside React, Vue and Angular: a DOM-free render for servers, a framework-free client and a single standalone file for plain pages, the host catalog for BI tools, flows, notebooks and CMSs, and a conformance kit.

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.

shell
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).

json
{ "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" }
FieldType
chartstring, requiredThe chart's slug: one of the 60 (bar-chart, donut-chart…).
dataarrayThe rows; without it the chart draws its demo data.
propsobjectThe chart's own props and the common view props (title, badge, dataTable, seed, hatchFill…).
width / heightnumber160..1600 × 90..1200.
ground / substratestringsilverpoint (cream, green, blue, ochre) or cyanotype (prussian).
mode'ink' | 'precision'Ink by default.
palettestring | objectA 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.

html
<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>
FileWhatgzip budget
silverpoint-embed.js / .mjsThe script (global Silverpoint) / the ES module140 kB
silverpoint-embed.full.js / .full.mjsThe same with EB Garamond's three cuts inlined220 kB
Note
An invalid spec draws an error figure naming the problem and reports 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.

ts
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.

ts
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.

ts
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):

HostCodeKindThroughPackageStatus
Power BIrepositorybiembedsilverpoint-powerbireleasedA custom visual: fields on roles, any of the tabular charts.
Tableaurepositorybiembedsilverpoint-tableaureleasedViz extensions, one manifest per chart, drawing on a worksheet.
KNIMErepositoryworkflowpythonsilverpoint-knimereleasedView nodes that draw a chart from a table, through the Python package.
n8nrepositoryworkflowembedn8n-nodes-silverpointreleasedA community node that draws a chart from workflow items, as SVG or HTML.
Apache Supersetrepositorybireactsuperset-plugin-chart-silverpointreleasedVisualization plugins, one per chart, drawn by the React adapter.
Plone Voltorepositorycmsreactvolto-silverpointreleasedA block that draws a chart from a table, server-rendered and hydrated.
Plone Classic UIrepositorycmspythoncollective.silverpointreleasedA Chart content type and a view for templates, through the Python package.
PythonrepositorylanguageembedsilverpointreleasedA chart from a DataFrame as self-contained HTML; the standalone file vendored.
Flaskin silverpointwebpythonsilverpoint[flask]releasedJinja globals and a route for the script, inside the Python package.
Djangoin silverpointwebpythonsilverpoint[django]releasedAn installable app with template tags, inside the Python package.
Jupyterin silverpointnotebookpythonsilverpointreleasedA chart as a cell output, in a sandboxed frame.
Databricks notebooksin silverpointnotebookpythonsilverpointreleasedA chart in a notebook cell with displayHTML; AI/BI dashboards are out (DD-072).
Note
Since silverpoint 0.11.2 every integration is released. Each has a guide here, with its install and examples: KNIME, n8n, Apache Superset, Plone (Volto and Classic), Power BI, Tableau, and Python, Flask, Django, Jupyter and Databricks.

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.

ts
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 →

json
{ "name": "generate_code",
  "arguments": { "target": { "chart": "donut-chart" }, "framework": "html" } }