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 ส่วนสำคัญของการแปลงเป็นพล็อตคือฟังก์ชัน 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 Lightweight และเข้ากันได้กับ Python 3.10+