fh plotly
v0.2.1
使用fasthtml的情節圖表。
pip install fh-plotly確保將正確的標題添加到您的Fasthtml應用程序:
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轉換為Plotly的要旨是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 )隨時打開問題或拉動請求。在進行貢獻時,請確保使用DEV依賴項進行可編輯的安裝。
pip install uv
uv sync進行測試:
pytest -s目的是保持fh-plotly ,並與Python 3.10+兼容。