feat(dashboard): даты по всей оси X, легенда вниз, крупнее шрифты, запоминаемый выбор упражнения, сводка по упражнению с синергичными

This commit is contained in:
Иван Овчинников
2026-11-20 07:47:39 +03:00
parent 97176ed90e
commit 7343a950f8
8 changed files with 244 additions and 39 deletions
+10 -8
View File
@@ -39,7 +39,7 @@ export function showChartDialog(exerciseName, clientId = null) {
const classes = points.map((_, i) => cls(i));
const topLabel = p => byWeight ? `${dayTop(p)}×${dayTopReps(p)}` : `${dayTop(p)}`;
const W = 320, H = 200, padL = 32, padR = 12, padT = 22, padB = 34;
const W = 320, H = 210, padL = 32, padR = 12, padT = 22, padB = 42;
const n = points.length;
const x = i => n === 1 ? (padL + W - padR) / 2
: padL + (W - padL - padR) * i / (n - 1);
@@ -82,17 +82,17 @@ export function showChartDialog(exerciseName, clientId = null) {
: '')
).join('');
const fmt = d => new Date(d).toLocaleDateString('ru-RU', { day: '2-digit', month: '2-digit' });
const counts = points.map((p, i) =>
(n <= 12 || i % 2 === 0)
? `<text x="${x(i).toFixed(1)}" y="${H - 16}" text-anchor="middle" class="chart-label chart-count">×${p.sets.length}</text>`
? `<text x="${x(i).toFixed(1)}" y="${H - 16}" text-anchor="middle" class="chart-label chart-count">×${p.sets.length}</text>` +
`<text x="${x(i).toFixed(1)}" y="${H - 4}" text-anchor="middle" class="chart-label chart-date-lab">${fmt(p.date)}</text>`
: ''
).join('');
const fmt = d => new Date(d).toLocaleDateString('ru-RU', { day: '2-digit', month: '2-digit' });
showModal(`
<div class="modal-header"><span class="modal-title">📈 ${escapeHtml(exerciseName)}</span><button class="btn-icon" onclick="closeModal()">✕</button></div>
<div class="chart-sub">главное — рабочий максимум «вес × повторы»: <b class="chart-up">зелёный — прогресс</b> (вес выше или тот же вес и больше повторов), <b class="chart-down">красный — откат</b>; тусклые точки — остальные подходы, ×N — их число</div>
<svg class="chart-svg" viewBox="0 0 ${W} ${H}">
<line x1="${padL}" y1="${y(vMin).toFixed(1)}" x2="${W - padR}" y2="${y(vMin).toFixed(1)}" class="chart-axis"/>
<line x1="${padL}" y1="${y(vMax).toFixed(1)}" x2="${W - padR}" y2="${y(vMax).toFixed(1)}" class="chart-axis"/>
@@ -102,10 +102,8 @@ export function showChartDialog(exerciseName, clientId = null) {
${segs.join('')}
${verts}
${counts}
<text x="${padL}" y="${H - 4}" class="chart-label">${fmt(points[0].date)}</text>
${n > 1 && new Date(points[n - 1].date) - new Date(points[0].date) > 864e5
? `<text x="${W - padR}" y="${H - 4}" text-anchor="end" class="chart-label">${fmt(points[n - 1].date)}</text>` : ''}
</svg>
<div class="chart-sub chart-legend-bottom">линия — рабочий максимум «вес × повторы»: <b class="chart-up">зелёный — прогресс</b> (вес выше или тот же вес и больше повторов), <b class="chart-down">красный — откат</b>; тусклые точки — остальные подходы, ×N — их число</div>
<div class="chart-list">${points.slice(-5).reverse().map((p, k) => {
const i = points.length - 1 - k;
return `<div class="chart-row"><span class="chart-date">${new Date(p.date).toLocaleDateString('ru-RU')}</span>` +
@@ -113,6 +111,10 @@ export function showChartDialog(exerciseName, clientId = null) {
`<span class="chart-sets">${p.sets.map(s => byWeight ? s.weight + '×' + s.reps : s.reps).join(' ')}` +
` · <span class="chart-count-num">${p.sets.length}</span> подх.</span></div>`;
}).join('')}</div>
<div style="display:flex; gap:8px; margin-top:10px">
<button class="btn btn-small btn-secondary" data-ex="${escapeHtml(exerciseName)}"
onclick="EM.showSummaryFromBtn(this)">📋 Сводка по упражнению</button>
</div>
`);
}