Skip to main content

Poetry 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 install with poetry install for an editable install with dev dependencies when working on contributions.

poetry install

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.1.1.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

fh_plotly-0.1.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fh_plotly-0.1.1.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for fh_plotly-0.1.1.tar.gz
Algorithm Hash digest
SHA256 aa41f39374a393e4fc8341e68646163522fe988d65fb1af6c80757b10e627020
MD5 00b7a2f08863f70e0b0f02bff5494a2b
BLAKE2b-256 5306ae830932f483a40091382d624b2c53b5649bff23736894193f909d498ae8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: fh_plotly-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0

File hashes

Hashes for fh_plotly-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a59bdf60dd56484026ca98e1468ff64137982475b499930a73e34664d856269b
MD5 b671b41a81c3c0de1f8324daa160e188
BLAKE2b-256 58db8092fefa05684bd192480dd538c4dd297fb1d8e903cf0ffaa33ae1c3c8ba

See more details on using hashes here.

Supported by

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