PlotlyChart¶
Render a Plotly figure through Hedron's bounded adapter pipeline.
| Import | from hedron_charts import PlotlyChart |
| Distribution | hedron-charts[plotly] |
| Backend activity | No |
| Normal render mode | RenderMode.FRAGMENT |
Live demo¶
The preview is a local docs simulation (not a running Hedron server). Interactive demos show a “Simulated HTMX” trace when applicable.
Install the optional provider before importing this component:
Basic use¶
from hedron_charts import PlotlyChart
import plotly.graph_objects as go
fig = go.Figure(data=[go.Bar(x=['IAD', 'PDX'], y=[120, 80])])
component = PlotlyChart(fig, title='Requests by region', description='US East handles the largest share.')
Compose under Page for full documents, or return from a fragment route for HTMX swaps.
How it works¶
The adapter compiles the figure into the supported static or browser representation, enforces visualization limits, and attaches accessible metadata and fallback content.
The server emits bounded, non-executable JSON and accessible metadata. The interactive visual requires the corresponding vendored browser host/runtime; these adapters remain Experimental and fail closed when the runtime is unavailable.
Constructor and parameters¶
| Parameter | Type | Meaning |
|---|---|---|
figure |
Plotly figure |
Figure specification. |
title / description / alt |
str | None |
Accessible metadata. |
waiver |
str | None |
Reviewed exception. |
Composition and backend behavior¶
Keep PlotlyChart at the smallest semantic boundary. Fragment routes should return only
the replaced region and preserve stable target IDs across success, validation, empty,
loading, and error responses.
PlotlyChart renders data the server already prepared. Keep queries, authorization, and redaction on the route or data source — do not treat the component as a place for side effects.
Accessibility¶
Make hover-only values available through labels or a table and ensure keyboard users can reach any enabled controls.
Security¶
Escaping and SafeUrl / TrustedHtml are framework concerns; authorization and data
exposure remain application code. Redact secrets before rendering.
Common mistakes¶
- Do not pass untrusted custom HTML, JavaScript callbacks, or unbounded traces.
- Do not copy docs-preview JavaScript into an application server.