diff --git a/materials/build_dashboard.py b/materials/build_dashboard.py index c94b2cd..5f44b6e 100644 --- a/materials/build_dashboard.py +++ b/materials/build_dashboard.py @@ -277,6 +277,9 @@ HTML = r""" .card .k{color:var(--muted);font-size:13px} .card .v{font-size:28px;font-weight:700;margin-top:4px} .card .c{color:var(--muted);font-size:12px;margin-top:6px} + .chart{background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:14px 12px 6px} + .legend{display:flex;gap:16px;flex-wrap:wrap;font-size:13px;margin:0 6px 6px;color:var(--muted)} + .legend i{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:5px;vertical-align:middle} table{width:100%;border-collapse:collapse;background:var(--panel); border:1px solid var(--line);border-radius:10px;overflow:hidden;font-size:13.5px} th,td{padding:9px 11px;text-align:left;border-bottom:1px solid var(--line);vertical-align:top} @@ -307,6 +310,9 @@ HTML = r"""

四维等级

+

等级趋势

+
+

掌握概览

@@ -406,6 +412,47 @@ document.getElementById("history").innerHTML = (DATA.history.map(h => `${esc(h.date)} ${esc(h.text)}`).join("") || "") + ``; +// 等级趋势图(从训练日志的每次等级画线) +(function () { + const LV = {A1:1, A2:2, B1:3, B2:4, C1:5, C2:6}; + const val = s => { + const m = String(s || "").trim().toUpperCase().match(/^([ABC])([12])(\+?)/); + return m ? LV[m[1] + m[2]] + (m[3] ? 0.5 : 0) : null; + }; + const SK = [ + {k:"listening", l:"听", c:"#4da3ff"}, {k:"speaking", l:"说", c:"#f1c40f"}, + {k:"reading", l:"读", c:"#2ecc71"}, {k:"writing", l:"写", c:"#e879f9"}]; + const el = document.getElementById("chart"); + const pts = DATA.log.slice().sort((a, b) => a.date < b.date ? -1 : 1) + .map(r => ({date: r.date, v: Object.fromEntries(SK.map(s => [s.k, val(r[s.k])]))})); + if (!pts.some(p => SK.some(s => p.v[s.k] != null))) { + el.innerHTML = '
暂无趋势数据
'; return; + } + const W = 760, H = 320, L = 46, R = 18, T = 16, B = 40, ymin = 0.7, ymax = 6.3; + const xs = i => L + (pts.length === 1 ? (W - L - R) / 2 : i * (W - L - R) / (pts.length - 1)); + const ys = v => T + (ymax - v) * (H - T - B) / (ymax - ymin); + let g = ""; + ["A1","A2","B1","B2","C1","C2"].forEach((lab, i) => { + const y = ys(i + 1); + g += ``; + g += `${lab}`; + }); + pts.forEach((p, i) => { + g += `${p.date.slice(5)}`; + }); + SK.forEach(s => { + const seq = pts.map((p, i) => ({i, v: p.v[s.k]})).filter(o => o.v != null); + if (!seq.length) return; + if (seq.length > 1) + g += ``; + seq.forEach(o => { + g += `${s.l} ${o.v} · ${pts[o.i].date}`; + }); + }); + el.innerHTML = `
` + SK.map(s => `${s.l}`).join("") + + `
${g}`; +})(); + renderItems();