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: Stable · Package line: 1.0.x · requires hedron-core>=1.0.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]>=1.0.0"
# independent satellite:
pip install "hedron-charts>=1.0.0,<2.0"
# Add a backend when needed:
pip install "hedron-charts[matplotlib]>=1.0.0,<2.0"

For applications, keep the flagship extra on the 1.0.x train; direct package consumers may use the Stable hedron-charts>=1.0.0,<2.0 SemVer range.

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.

License

MIT. See the repository license.

Release files for hedron-charts 1.1.0

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 1.1.0
File Size Uploaded
hedron_charts-1.1.0.tar.gz 2.9 MB Details

Built distribution (wheel)

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

Total release size: 5.9 MB

Release files / hedron_charts-1.1.0.tar.gz

Download URL hedron_charts-1.1.0.tar.gz
Size 2.9 MB
Tags Source
SHA-256 checksum
How to use checksums
02cd8c180b45966bcfae382da969fa05cc4756dec1bc290e8b96c78858ee0168
BLAKE2b-256 checksum
How to use checksums
a9ca59fefc75b19082027dcea401f01b4683571c18c0410b562538f618ed1e86
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-1.1.0-py3-none-any.whl

Download URL hedron_charts-1.1.0-py3-none-any.whl
Size 2.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
df3c25b4fc3631bc92312923d9524b6a7012218310cd3edde03e0f2d22a7607a
BLAKE2b-256 checksum
How to use checksums
97d7cec8565b6cd1f8593faa1cd8bc0fed35fcf482c3ba4c51bf26feb8cd3551
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

This release

1.1.0 This release

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

0.2.2

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