Article 30 introduced @silverpoint/embed, the engine that draws a chart from a JSON spec. This article takes it to Python with the silverpoint package on PyPI, and uses it in the two notebooks most often seen in data analysis: Jupyter and Databricks. Flask and Django have their own article, 32.

One clarification before starting. If you are building an application with Reflex, the package you want is reflex-silverpoint-react, which wraps the React components along with the UI components and the dashboard. silverpoint is for everything else in Python: notebooks, Flask, Django, scripts and static HTML.

Three charts written by the Python package from three DataFrames: horizontal bars of wins, a line on cyanotype and a load heatmap

Install

silverpoint needs Python 3.10 or later and has no dependencies. The flask and django extras bring the matching framework.

pip install silverpoint            # no dependencies
pip install "silverpoint[flask]"   # or [django]
# or
uv add silverpoint

Version X.Y.Z of the package carries the @silverpoint/embed standalone file of the same version X.Y.Z (you can check it in silverpoint.SILVERPOINT_VERSION). No image is made in Python: the package writes the spec and the HTML that carries it, and the silverpoint engine draws in the browser, just as in React, Vue or Angular.

A chart

Each builder function takes the data, one keyword per role (a column's name) and one per option, and returns a Chart object. Its spec attribute is the spec @silverpoint/embed draws, built and validated when the chart is created.

import pandas as pd
import silverpoint

df = pd.DataFrame({"team": ["A", "B", "C"], "wins": [12, 9, 15]})
chart = silverpoint.bar_chart(df, x="team", value="wins", orientation="rows", title="Wins")

chart.spec        # the ChartSpec, a dict
chart.to_html()   # a complete, self-contained page (the script inlined; no network)
chart.to_svg()    # the library's renderToSVG bytes (needs Node 20+ on PATH)

This is the spec left in chart.spec:

{'chart': 'bar-chart',
 'data': [{'team': 'A', 'wins': 12}, {'team': 'B', 'wins': 9}, {'team': 'C', 'wins': 15}],
 'props': {'orientation': 'rows', 'title': 'Wins', 'xKey': 'team', 'valueKey': 'wins'}}

Chart(slug, data, roles=…, options=…) does the same from the chart's identifier. Both forms take the appearance (ground, substrate, mode and palette), width, height and id. The common props are written in snake_case (data_table, footer_left, hatch_fill…). There is one exception: the common value prop, the figure in the card's header, is written value_, because value already names a role.

# the same chart, by slug: roles are the columns, options the chart's props
chart = silverpoint.Chart(
    "bar-chart",
    df,
    roles={"x": "team", "value": "wins"},
    options={"orientation": "rows", "title": "Wins"},
    ground="silverpoint", substrate="green", mode="precision", palette="verdigris",
    width=480,
)

silverpoint.catalog["version"]   # the host catalog the builders are generated from
silverpoint.SILVERPOINT_VERSION   # the @silverpoint/embed version vendored

There is one function per chart a table can feed: 56 of the 60. They are generated from the host catalog with full type hints, so the editor completes each chart's roles and the values of its options.

The data it takes

Rows, a mapping of columns, a pandas or polars DataFrame, a pyarrow table and, in Databricks, a Spark or pandas-on-Spark DataFrame, or the Rows that collect() returns. Charts drawn from a matrix, such as the heatmap, take the table in long format and the package reshapes it: row, column and value are three columns.

import polars as pl
import pyarrow as pa

rows = [{"team": "A", "wins": 12}, {"team": "B", "wins": 9}]   # a list of rows
columns = {"team": ["A", "B"], "wins": [12, 9]}                 # a mapping of columns

silverpoint.bar_chart(rows, x="team", value="wins")
silverpoint.bar_chart(columns, x="team", value="wins")
silverpoint.bar_chart(pl.DataFrame(columns), x="team", value="wins")
silverpoint.bar_chart(pa.table(columns), x="team", value="wins")
# dates become ISO strings; NaN and NaT become None

Errors come before the HTML

A role, column, option or value the catalog does not know raises SpecError when the chart is created, with the closest valid names. A page with a chart that cannot draw is never written.

from silverpoint import SpecError

try:
    silverpoint.bar_chart(df, x="teem", value="wins")
except SpecError as error:
    print(error.kind, error)
# role the data has no column "teem" Did you mean "team"?. Columns: "team", "wins".

silverpoint.bar_chart(df, x="team", value="wins", orientation="sideways")
# SpecError: bar-chart: "sideways" is not a value of `orientation`; its values are "columns", "rows".

silverpoint.Chart("bar-chrt")
# SpecError: Unknown chart "bar-chrt". Did you mean "bar-chart"?
ExceptionWhen
SpecErrorA chart, role, column, option or value the catalog does not know; error.kind is chart, role, prop, shape or value
RuntimeUnavailableto_svg() or render="server" with no Node 20 or later on PATH
ValueErrorA Spark DataFrame over 10,000 rows (SPARK_ROW_LIMIT): aggregate in Spark first

Jupyter, JupyterLab and VS Code

A chart as a cell's value draws itself. Each one is a sandboxed <iframe srcdoc> holding the whole page, so it needs no trusted notebook and its stylesheet does not mix with the notebook's.

import pandas as pd
import silverpoint

df = pd.DataFrame({"hour": ["00", "04", "08", "12", "16", "20"], "hits": [18, 11, 34, 71, 74, 62]})
silverpoint.line_chart(df, x="hour", value="hits", title="Hits per hour", curve="monotone")
# the chart is the cell's value: it draws itself in a sandboxed <iframe srcdoc>

# front ends that run scripts in outputs can share one copy of the script:
silverpoint.notebook.enable()    # shows the script once; later charts are <silverpoint-chart>
silverpoint.notebook.disable()   # back to one frame per chart

silverpoint.notebook.enable() shows the script once and writes the following charts as <silverpoint-chart> elements, for front ends that run scripts in outputs. The repository has an example notebook, quickstart.ipynb.

Databricks

In Databricks, a Spark DataFrame goes straight into the builder, and the chart as the cell's value draws itself. To draw several charts in one cell, displayHTML(chart.to_html(render="client")) draws each one where it is called.

# %pip install silverpoint
from pyspark.sql import functions as F
import silverpoint

trips = spark.read.table("samples.nyctaxi.trips")
by_hour = (
    trips.groupBy(F.hour("tpep_pickup_datetime").alias("hour"))
    .agg(F.count("*").alias("trips"), F.round(F.avg("fare_amount"), 2).alias("fare"))
    .orderBy("hour")
    .withColumn("hour", F.format_string("%02d:00", "hour"))
)

# a Spark DataFrame goes straight into a builder; the chart draws itself as the cell's value
silverpoint.line_chart(by_hour, x="hour", value="trips", secondary="fare", title="Trips per pickup hour")

# several charts in one cell: displayHTML draws each where it is called
displayHTML(silverpoint.bar_chart(by_hour, x="hour", value="trips").to_html(render="client"))

The example uses the samples.nyctaxi.trips table, which comes with any workspace; the repository has the notebook ready to import, databricks.py. Three limits worth knowing:

  • Rows. At most 10,000 rows are read (silverpoint.data.SPARK_ROW_LIMIT) through limit, so a large table never reaches the driver. A bigger DataFrame raises ValueError: aggregate in Spark first.
  • Size. Each chart carries its own copy of the script: about 0.5 MB, 1.1 MB with 10,000 rows. A cell's output may take 10 MB by default on Runtime 17 or later, and a notebook keeps about fifteen charts before Databricks stops saving its revisions.
  • silverpoint.notebook.enable() has no effect in Databricks and warns: each output is a frame of its own.

It cannot be used in Databricks AI/BI dashboards; design decision DD-072 leaves them out.

Static HTML and SVG

Outside a notebook, to_html() writes a page that opens from disk, works as a report or as an e-mail attachment. to_svg() returns the output of the library's renderToSVG (with embed_fonts=True it includes EB Garamond) and, like render="server", needs Node 20 or later. A CDN URL is never written.

from pathlib import Path

# a self-contained page: the vendored script inlined, no network, opens from disk
Path("wins.html").write_text(chart.to_html())

# a fragment for a page that loads the script itself
box = chart.to_html(full_document=False, render="client")
# <div data-sp-embed><script type="application/json">{"chart":"bar-chart",…}</script></div>

# a page whose script your application serves (never a CDN), pinned by its integrity
page = chart.to_html(script="/static/silverpoint-embed.full.js", integrity="sha384-…")

silverpoint.static_path()   # the folder holding silverpoint-embed.full.js, for any framework
to_html optionDefaultWhat it does
full_documentTrueA whole page or only the chart's markup
script"inline""inline" (the file inside the page), "none" (the page loads it) or a URL your application serves
render"auto""server" draws in Node with renderToHTML; "client" writes only the spec and the script draws; "auto" uses the server when Node is on PATH
title / langthe chart's name / "en"The page's <title> and lang
integrityNoneThe script's SHA-384, when a URL is passed

The images in this article were made this way: each chart's to_html(), opened in a browser.

If the spec comes from elsewhere, for example from the MCP server's generate_code, Chart.from_spec turns it into a chart:

# a spec written elsewhere, for instance by the MCP server's generate_code
chart = silverpoint.Chart.from_spec({
    "chart": "donut-chart",
    "data": [{"name": "Rent", "value": 38}, {"name": "Food", "value": 22}],
    "props": {"nameKey": "name", "valueKey": "value", "title": "Budget"},
})
chart.to_html()

Next