fh plotly
v0.2.1
Verwenden Sie Plotly -Diagramme mit fasthtml.
pip install fh-plotlyStellen Sie sicher, dass Sie Ihre fasthtml -App die richtigen Header hinzufügen:
from fasthtml . common import fast_app
from fh_plotly import plotly_headers
app , rt = fast_app ( hdrs = plotly_headers )Dies stellt sicher, dass die erforderlichen JavaScript- und CSS -Dateien immer geladen sind.
Führen Sie examples/test_app.py aus, um einige grundlegende Diagramme anzuzeigen.
python examples/test_app.py Der Umwandlungsgericht zu Plotly ist die plotly2fasthtml -Funktion.
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 )Fühlen Sie sich frei, ein Problem oder eine Pull -Anfrage zu öffnen. Stellen Sie sicher, dass Sie bei der Arbeit an Beiträgen eine bearbeitbare Installation mit Dev -Abhängigkeiten durchführen.
pip install uv
uv syncTests ausführen:
pytest -s Ziel ist es, fh-plotly leichte und kompatibel mit Python 3.10+ zu halten.