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+兼容。