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.2.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.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

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

Hashes for fh_plotly-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3450bc1f386345b189043778a94c50a659d95843becd2b34c88fc7300d966c4e
MD5 db3678241ff473202120946e00685314
BLAKE2b-256 54230a404c8f991008bbab6907a1ca43006546df581554882712192c941e2b07

See more details on using hashes here.

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

Hashes for fh_plotly-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ccfa12b76baf04f8861bd45fc725a210eef97e2f91cb5cd969acfaece082dad5
MD5 af0b72c03455feb9b9bf1e009dcb295c
BLAKE2b-256 ac5b5ffdb6d735e849f00cad900263aff0deb6226b3d3184ef138c618310fedb

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