diff --git a/app.py b/app.py index bad2ff6..7ed69f8 100644 --- a/app.py +++ b/app.py @@ -8,6 +8,15 @@ from plotly.subplots import make_subplots from simulator import run_wofost, run_multi_crop, list_available_crops, CROP_META + +def hex_to_rgba(hex_color: str, alpha: float = 0.1) -> str: + hex_color = hex_color.lstrip("#") + r = int(hex_color[0:2], 16) + g = int(hex_color[2:4], 16) + b = int(hex_color[4:6], 16) + return f"rgba({r}, {g}, {b}, {alpha})" + + # ─── Page Config ──────────────────────────────────────────────────────────── st.set_page_config( page_title="麦麦智农", @@ -274,7 +283,7 @@ with chart_left: mode="lines", line=dict(color=crop_info["color"], width=2.5), fill="tozeroy", - fillcolor=crop_info["color"] + "1A", + fillcolor=hex_to_rgba(crop_info["color"], 0.1), name="LAI", )) # 添加生育期标记