Skip to main content

Plotly in FastHTML

Project description

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+.

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

fh_plotly-0.2.4.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fh_plotly-0.2.4-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file fh_plotly-0.2.4.tar.gz.

File metadata

  • Download URL: fh_plotly-0.2.4.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.4

File hashes

Hashes for fh_plotly-0.2.4.tar.gz
Algorithm Hash digest
SHA256 96b874b44ba2afbf0f446520b7a8db42564d035ee06d0c423f9cd0b3dd4344f2
MD5 4c09def192dd620680f76fcf4caadc53
BLAKE2b-256 e6b669687ff3792b2b6c75365bf70cf0409e3ff579e69dd8da09fcf2c32b6629

See more details on using hashes here.

File details

Details for the file fh_plotly-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: fh_plotly-0.2.4-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.12.4

File hashes

Hashes for fh_plotly-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 00f455251b2efb7041e7bbf37f0e1c0194c0c3e43940b763529d014a980215dd
MD5 08c8f217e5a7d1dfabc1a13d3967ac9c
BLAKE2b-256 bbb675d9bcb483ad0f5a77346813d6a3b1de6de5f5449b72475636711428b350

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page