Skip to main content

fh-plotly

Downloads Python uv Ruff

Use Plotly charts with FastHTML.

Installation

pip install fh-plotly

Make sure to add the right headers to your FastHTML app:

from fasthtml.common import fast_app
from fh_plotly import plotly_headers

app, rt = fast_app(hdrs=plotly_headers)

This ensures that the required javascript and css files are always loaded.

Examples

Run examples/test_app.py to see some basic plots.

python examples/test_app.py

The gist of conversion to Plotly is the plotly2fasthtml function.

from fh_plotly import plotly2fasthtml

def generate_line_chart():
    df = pd.DataFrame({'y': [1, 2, 3, 2], 'x': [3, 1, 2, 4]})
    fig = px.line(df, x='x', y='y')
    return plotly2fasthtml(fig)

Contributing

Feel free to open an issue or a pull request. Make sure to do an editable install with dev dependencies when working on contributions.

pip install uv
uv sync

To run tests:

pytest -s

The goal is to keep fh-plotly lightweight and compatible with Python 3.10+.

Metadata

Release files for fh-plotly 0.2.4

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

Source distribution (sdist)

Source distribution for fh-plotly 0.2.4
File Size Uploaded
fh_plotly-0.2.4.tar.gz 4.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fh-plotly 0.2.4
File Interpreter ABI Platform
fh_plotly-0.2.4-py3-none-any.whl Python 3 none any Details

Total release size: 8.0 kB

Release files / fh_plotly-0.2.4.tar.gz

Download URL fh_plotly-0.2.4.tar.gz
Size 4.2 kB
Tags Source
SHA-256 checksum
How to use checksums
96b874b44ba2afbf0f446520b7a8db42564d035ee06d0c423f9cd0b3dd4344f2
BLAKE2b-256 checksum
How to use checksums
e6b669687ff3792b2b6c75365bf70cf0409e3ff579e69dd8da09fcf2c32b6629
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.4

Release files / fh_plotly-0.2.4-py3-none-any.whl

Download URL fh_plotly-0.2.4-py3-none-any.whl
Size 3.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
00f455251b2efb7041e7bbf37f0e1c0194c0c3e43940b763529d014a980215dd
BLAKE2b-256 checksum
How to use checksums
bbb675d9bcb483ad0f5a77346813d6a3b1de6de5f5449b72475636711428b350
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.4

Release history Release notifications | RSS feed

This release

0.2.4 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

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