Commit 984f70d2 authored by 郭阔's avatar 郭阔

fix(dashboard): 修复趋势图柱子不可见(百分比高度无参照),加网格线与Y轴刻度

align-items:flex-end 使柱体塌缩为内容高度,分段 height:% 无参照全为 0。
改为 stretch+column-reverse,高度按向上取整的轴最大值归一;
补 25/50/75/100% 网格线与数值刻度,顶部留白与刻度对齐。
parent 184feb52
......@@ -16,6 +16,7 @@
import functools
import json
import math
import os
import re
import subprocess
......@@ -1366,6 +1367,7 @@ def dashboard():
sites = sorted({r["site"] for r in rows if r["d7"] > 0},
key=lambda s: -sum(per_day[d].get(s, 0) for d in days))
chart_max = max([sum(v.values()) for v in per_day.values()] or [1]) or 1
chart_axis_max = int(math.ceil(chart_max / 20.0) * 20)
bars = []
for d in days:
segs, y = [], 100.0
......@@ -1374,14 +1376,14 @@ def dashboard():
v = per_day[d].get(s, 0)
if not v:
continue
h = v / chart_max * 100
h = v / chart_axis_max * 100
y -= h
segs.append({"site": s, "v": v, "y": round(y, 1), "h": round(h, 1),
"color": SITE_COLORS.get(s, "#8a8f98")})
bars.append({"day": d, "total": total, "segs": segs})
rows.sort(key=lambda r: (-r["today"], -r["d7"]))
active = _active_harvests()
return render_template("dashboard.html", rows=rows, bars=bars, days=days,
return render_template("dashboard.html", rows=rows, bars=bars, days=days, chart_axis_max=chart_axis_max,
sites=[(s, SITE_COLORS.get(s, "#8a8f98"),
sum(per_day[d].get(s, 0) for d in days)) for s in sites],
tot=tot, today=today, active=active,
......
......@@ -7,8 +7,10 @@
.kpi .card { padding:14px 16px; }
.kpi .num { font-size:26px; font-weight:700; line-height:1.2; }
.kpi .sub { color:#888; font-size:12px; margin-top:2px; }
.chart { display:flex; align-items:flex-end; gap:6px; height:180px; margin:10px 0 4px; }
.chart .bar { flex:1; display:flex; flex-direction:column; justify-content:flex-end; position:relative; min-width:0; }
.chart { display:flex; align-items:stretch; gap:6px; height:200px; margin:10px 0 4px; position:relative; padding-left:44px; }
.chart .grid { position:absolute; left:44px; right:0; border-top:1px dashed #2a2d37; }
.chart .grid span { position:absolute; left:-42px; top:-7px; width:36px; text-align:right; font-size:11px; color:#666; }
.chart .bar { flex:1; display:flex; flex-direction:column-reverse; position:relative; min-width:0; }
.chart .seg { width:100%; }
.chart .bar .total { position:absolute; top:-20px; width:100%; text-align:center; font-size:12px; color:#aaa; }
.chart-labels { display:flex; gap:6px; margin-top:22px; }
......@@ -36,6 +38,9 @@
<h2>每日产出(按站点堆叠)</h2>
<div class="chart">
{% for g in [100, 75, 50, 25] %}
<div class="grid" style="bottom:{{ g }}%"><span>{{ (chart_axis_max * g / 100)|int }}</span></div>
{% endfor %}
{% for b in bars %}
<div class="bar" title="{{ b.day }} 共 {{ b.total }} 篇{% for s in b.segs %}&#10;{{ s.site }}: {{ s.v }}{% endfor %}">
{% if b.total %}<div class="total">{{ b.total }}</div>{% endif %}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment