fh plotly
v0.2.1
fastthtmlを使用してプロットチャートを使用します。
pip install fh-plotly正しいヘッダーをfastthtmlアプリに追加してください。
from fasthtml . common import fast_app
from fh_plotly import plotly_headers
app , rt = fast_app ( hdrs = plotly_headers )これにより、必要なJavaScriptおよびCSSファイルが常にロードされることが保証されます。
いくつかの基本的なプロットを表示するには、 examples/test_app.pyを実行します。
python examples/test_app.pyプロットリーへの変換の要点は、 plotly2fasthtml関数です。
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 )お気軽に問題やプルリクエストを開いてください。貢献に取り組んでいるときは、開発の依存関係を備えた編集可能なインストールを必ず実行してください。
pip install uv
uv syncテストを実行するには:
pytest -s目標は、Python 3.10+と互換性があり、 fh-plotly lightweightを維持することです。