Plotly in FastHTML
Project description
fh-plotly
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+.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fh_plotly-0.2.2.tar.gz.
File metadata
- Download URL: fh_plotly-0.2.2.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3450bc1f386345b189043778a94c50a659d95843becd2b34c88fc7300d966c4e
|
|
| MD5 |
db3678241ff473202120946e00685314
|
|
| BLAKE2b-256 |
54230a404c8f991008bbab6907a1ca43006546df581554882712192c941e2b07
|
File details
Details for the file fh_plotly-0.2.2-py3-none-any.whl.
File metadata
- Download URL: fh_plotly-0.2.2-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.9.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccfa12b76baf04f8861bd45fc725a210eef97e2f91cb5cd969acfaece082dad5
|
|
| MD5 |
af0b72c03455feb9b9bf1e009dcb295c
|
|
| BLAKE2b-256 |
ac5b5ffdb6d735e849f00cad900263aff0deb6226b3d3184ef138c618310fedb
|