Skip to main content

hedron-charts

PyPI Python CI License: MIT

First-party charts, deterministic exports, and optional plotting-library adapters for Hedron.

Beginner LineChart / BarChart / AreaChart / ScatterChart, Matplotlib static SVG/PNG, Plotly interactive JSON, and Altair/Vega-Lite specifications.

Package maturity: Beta · Package version: 0.2.0

Interactive Plotly/Vega full browser runtimes remain experimental: Hedron ships host shims that fail closed when window.Plotly / window.vegaEmbed are missing. Applications may supply pinned local runtimes; first-party offline runtime pins exist for Experimental interactive hosts and are not Supported production Auto defaults.

Phase 0.38 first-party charts

Phase 0.38 ships hedron-charts 0.2.0 with schema-driven ChartSpec / ChartPlan, an ABI-conforming hedron-chart Web Component, semantic server fallbacks, SVG by default, Canvas for dense series, core inspect/focus/select/reset events, deterministic server exports, and bounded payloads. The current host has dedicated paint behavior for line, area, bar, and point; broader schema acceptance does not imply a specialized painter. Matplotlib remains Supported; Plotly/Altair stay Experimental. See RFC-0069 and the phase 0.38 acceptance packet.

Install

# flagship extra:
pip install "hedron[charts]>=0.64.0,<0.65"
# independent satellite:
pip install "hedron-charts>=0.2.1,<0.3"
# Add a backend when needed:
pip install "hedron-charts[matplotlib]>=0.2.1,<0.3"

Pin the living charts line at >=0.2.0,<0.3 on the 0.51 train.

Optional backends

Extra Backend
matplotlib Matplotlib static SVG/PNG
plotly Plotly figure JSON
altair Altair / Vega-Lite (+ vl-convert)
pydeck / folium Map layers
graphviz / networkx Graph layouts
bokeh / holoviews / pygal / datashader / great_tables Additional adapters
all Union of the above

Backend extras are optional and should be installed only for the adapter in use.

Choose an entry point

Need Use Runtime
A line, area, bar, or scatter chart from row mappings LineChart, AreaChart, BarChart, ScatterChart First-party hedron-chart; useful server fallback without JavaScript
A validated declarative specification Chart + ChartSpec First-party hedron-chart
A server-rendered Matplotlib figure MatplotlibChart Static SVG or PNG; no browser plotting runtime
An existing Plotly or Altair figure PlotlyChart / AltairChart Vendored browser runtime; Experimental explicit opt-in

The beginner components do not select Matplotlib automatically. They compile to the first-party ChartSpec / ChartPlan path.

Quick start

from hedron_charts import LineChart

chart = LineChart(
    [{"month": "Jan", "revenue": 10}, {"month": "Feb", "revenue": 14}],
    x="month",
    y="revenue",
    title="Monthly revenue",
    description="Revenue increased during the period.",
)

The response contains a semantic figure, summary, and bounded table fallback. The local hedron-chart module progressively enhances it to SVG or Canvas and remounts after HTMX swaps.

For an explicit Matplotlib figure:

import matplotlib.pyplot as plt
from hedron_charts import MatplotlibChart

fig, ax = plt.subplots()
ax.plot([1, 2, 3], [1, 4, 9])
chart = MatplotlibChart(fig, alt="y = x squared", description="Quadratic growth")

Advanced specification and export

from hedron_charts import Chart, compile_chart, export_csv, parse_chart_spec

spec = parse_chart_spec(
    {
        "data": {
            "rows": [
                {"month": "Jan", "revenue": 10},
                {"month": "Feb", "revenue": 14},
            ]
        },
        "marks": [
            {
                "type": "line",
                "encodings": {
                    "x": {"field": "month", "type": "string"},
                    "y": {"field": "revenue", "type": "number"},
                },
            }
        ],
        "accessibility": {
            "title": "Monthly revenue",
            "description": "Revenue increased from January to February.",
        },
    }
)

chart = Chart(spec)
plan = compile_chart(spec)
csv_text = export_csv(plan, authorized=user_can_export)

Unknown schema fields, mark types, encoding channels, scales, and transform operators fail closed with HED-CHART-* diagnostics. Perform export authorization in application code; the default authorized=True argument is intended for already-authorized internal calls.

The compiler also accepts advanced mark families, guide metadata, and interaction flags that the 0.2.0 browser host does not yet paint or operate with dedicated behavior. Review the runtime coverage matrix before choosing the first-party host for advanced visualizations.

Links

License

MIT. See the repository license.

Release files for hedron-charts 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hedron-charts 0.2.2
File Size Uploaded
hedron_charts-0.2.2.tar.gz 2.9 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for hedron-charts 0.2.2
File Interpreter ABI Platform
hedron_charts-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 5.9 MB

Release files / hedron_charts-0.2.2.tar.gz

Download URL hedron_charts-0.2.2.tar.gz
Size 2.9 MB
Tags Source
SHA-256 checksum
How to use checksums
52c00603c4d2378b9ef347c0b5d8e20f031ac0507ff966fb4aae0c3e36233d64
BLAKE2b-256 checksum
How to use checksums
d793daa18596f26af345860a2f642d7c72a5b5a6caa2dab819ec7763401f0d99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / hedron_charts-0.2.2-py3-none-any.whl

Download URL hedron_charts-0.2.2-py3-none-any.whl
Size 2.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
07e1d52a59cd0b07c2828f2863ebb0eaae51d750419e75cb460e1dd8eb29df28
BLAKE2b-256 checksum
How to use checksums
bfd2e17fbd16160231c285bd55818e551ad3a72502589b38fdbb266198bdb734
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.18

2 release files

1.0.17

2 release files

1.0.16

2 release files

1.0.15

2 release files

1.0.14

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.11

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page