Chart
Chart renders Matplotlib, Plotly, Altair, or raw SVG and HTML outputs in a single component.
Quick Start
Plotly and Altair
If your figure object exposes to_html(), Chart can render it directly.
Raw SVG or HTML
Raw strings require explicit opt-in for safety:
Backend Inference
If you pass a Matplotlib or Plotly/Altair object, Chart will infer the backend automatically. Raw strings always require backend to be specified.
Sizing and Responsiveness
responsive=Trueaddsw-100to the wrapper.- Use
widthandheightfor fixed sizing.
Theming
Chart does not auto-theme plots. Use your chart library to set colors for dark mode and match your theme palette.
Security Notes
If you render raw SVG or HTML, only use trusted content. Set allow_unsafe_html=True only when you control the source.
API Reference
faststrap.components.display.chart.Chart(figure, *, backend=None, include_js=False, responsive=True, width=None, height=None, allow_unsafe_html=False, **kwargs)
Render a chart from common Python plotting backends.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
figure
|
Any
|
Matplotlib figure, Plotly/Altair chart, or raw SVG/HTML string. |
required |
backend
|
ChartBackend | None
|
Explicit backend name. If None, attempts to infer from object. |
None
|
include_js
|
bool
|
Include Plotly JS when rendering Plotly charts. |
False
|
responsive
|
bool
|
Apply responsive sizing classes. |
True
|
width
|
str | int | None
|
Optional width (px or CSS string). |
None
|
height
|
str | int | None
|
Optional height (px or CSS string). |
None
|
allow_unsafe_html
|
bool
|
Allow raw HTML/SVG strings to be embedded. |
False
|
**kwargs
|
Any
|
Additional HTML attributes for the wrapper. |
{}
|