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 version: 1.0.0 · 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,<1.1"
# 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.

Links

License

MIT. See the repository license.

Release files for hedron-charts 1.0.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.0.0
File Size Uploaded
hedron_charts-1.0.0.tar.gz 2.9 MB Details

Built distribution (wheel)

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

Total release size: 5.9 MB

Release files / hedron_charts-1.0.0.tar.gz

Download URL hedron_charts-1.0.0.tar.gz
Size 2.9 MB
Tags Source
SHA-256 checksum
How to use checksums
304002a41eb7d0ca5f4847922cb8bc1fab9678c98541d697afcafed154da9162
BLAKE2b-256 checksum
How to use checksums
685904618a736e54fee1bbb521e35a8803ddc3536bcba717eb4d311b8da92bb1
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.0.0-py3-none-any.whl

Download URL hedron_charts-1.0.0-py3-none-any.whl
Size 2.9 MB
Tags Python 3
SHA-256 checksum
How to use checksums
433ea70888303bcdb4cbce4923e5a23bea3184a6a5a95bbc7460514a8b74b79c
BLAKE2b-256 checksum
How to use checksums
8ae84fd5db77809e21e8ab443fa0fb5c5e47ea5cc8c4203aafcfe95dad8524a0
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

This release

1.0.0 This release

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