fix(chart): модалка графика на весь экран — обёртка modal-content, размер под вьюпорт, крупные подписи
This commit is contained in:
@@ -15,8 +15,10 @@ export function showChartDialog(exerciseName, clientId = null) {
|
||||
|
||||
if (points.length === 0) {
|
||||
showModal(`
|
||||
<div class="modal-content">
|
||||
<div class="modal-header"><span class="modal-title">${escapeHtml(exerciseName)}</span><button class="btn-icon" onclick="closeModal()">✕</button></div>
|
||||
<div class="history-hint" style="margin:8px 0">Нет завершённых тренировок с этим упражнением — график появится после первых результатов.</div>
|
||||
</div>
|
||||
`);
|
||||
return;
|
||||
}
|
||||
@@ -39,7 +41,10 @@ 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 = 210, padL = 32, padR = 12, padT = 22, padB = 42;
|
||||
// Полноэкранный график: размер под текущий вьюпорт, а не фиксированные 320px
|
||||
const W = Math.max(320, (window.innerWidth || 900) - 12);
|
||||
const H = Math.min(640, Math.max(300, Math.round((window.innerHeight || 700) * 0.52)));
|
||||
const padL = 46, padR = 34, padT = 36, padB = 58;
|
||||
const n = points.length;
|
||||
const x = i => n === 1 ? (padL + W - padR) / 2
|
||||
: padL + (W - padL - padR) * i / (n - 1);
|
||||
@@ -50,12 +55,12 @@ export function showChartDialog(exerciseName, clientId = null) {
|
||||
const y = v => padT + (H - padT - padB) * (1 - (v - vMin) / (vTop - vMin || 1));
|
||||
|
||||
const maxReps = Math.max(1, ...points.flatMap(p => p.sets.map(s => s.reps || 0)));
|
||||
const rOf = s => 1.6 + 2.2 * Math.min(1, (s.reps || 0) / maxReps);
|
||||
const rOf = s => 2.6 + 3.6 * Math.min(1, (s.reps || 0) / maxReps);
|
||||
|
||||
// Все подходы — тусклые фоновые точки, слегка раскиданные вокруг дня
|
||||
const dots = [];
|
||||
points.forEach((p, i) => {
|
||||
const spread = p.sets.length > 1 ? Math.min(9, (W - padL - padR) / (2 * n)) : 0;
|
||||
const spread = p.sets.length > 1 ? Math.min(20, (W - padL - padR) / (2 * n)) : 0;
|
||||
p.sets.forEach((s, k) => {
|
||||
if (byWeight && s.weight === p.maxWeight) return; // максимум покажет вершина линии
|
||||
const dx = p.sets.length > 1 ? -spread + 2 * spread * k / (p.sets.length - 1) : 0;
|
||||
@@ -74,30 +79,31 @@ export function showChartDialog(exerciseName, clientId = null) {
|
||||
`x2="${x(i).toFixed(1)}" y2="${y(dayTop(points[i])).toFixed(1)}" class="chart-seg ${classes[i]}"/>`);
|
||||
}
|
||||
// Вершины: крупная точка + подпись «вес×повт.» с цветом прогресса
|
||||
const showLabel = i => n <= 10 || i >= n - 5 || classes[i] !== 'chart-flat';
|
||||
const showLabel = i => n <= 12 || i >= n - 6 || classes[i] !== 'chart-flat';
|
||||
const verts = points.map((p, i) =>
|
||||
`<circle class="chart-vert ${classes[i]}" cx="${x(i).toFixed(1)}" cy="${y(dayTop(p)).toFixed(1)}" r="5.5"></circle>` +
|
||||
`<circle class="chart-vert ${classes[i]}" cx="${x(i).toFixed(1)}" cy="${y(dayTop(p)).toFixed(1)}" r="6.5"></circle>` +
|
||||
(showLabel(i)
|
||||
? `<text x="${x(i).toFixed(1)}" y="${(y(dayTop(p)) - 8).toFixed(1)}" text-anchor="middle" class="chart-label chart-vert-label ${classes[i]}">${topLabel(p)}</text>`
|
||||
? `<text x="${x(i).toFixed(1)}" y="${(y(dayTop(p)) - 11).toFixed(1)}" text-anchor="middle" class="chart-label chart-vert-label ${classes[i]}">${topLabel(p)}</text>`
|
||||
: '')
|
||||
).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>` +
|
||||
(n <= 16 || i % 2 === 0)
|
||||
? `<text x="${x(i).toFixed(1)}" y="${H - 20}" 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('');
|
||||
|
||||
showModal(`
|
||||
<div class="modal-content modal-fullscreen">
|
||||
<div class="modal-header"><span class="modal-title">📈 ${escapeHtml(exerciseName)}</span><button class="btn-icon" onclick="closeModal()">✕</button></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"/>
|
||||
<text x="${padL - 4}" y="${(y(vMax) + 3).toFixed(1)}" text-anchor="end" class="chart-label">${vMax}</text>
|
||||
<text x="${padL - 4}" y="${(y(vMin) + 3).toFixed(1)}" text-anchor="end" class="chart-label">${vMin}</text>
|
||||
<text x="${padL - 6}" y="${(y(vMax) + 4).toFixed(1)}" text-anchor="end" class="chart-label">${vMax}</text>
|
||||
<text x="${padL - 6}" y="${(y(vMin) + 4).toFixed(1)}" text-anchor="end" class="chart-label">${vMin}</text>
|
||||
${dots.join('')}
|
||||
${segs.join('')}
|
||||
${verts}
|
||||
@@ -115,6 +121,7 @@ export function showChartDialog(exerciseName, clientId = null) {
|
||||
<button class="btn btn-small btn-secondary" data-ex="${escapeHtml(exerciseName)}"
|
||||
onclick="EM.showSummaryFromBtn(this)">📋 Сводка по упражнению</button>
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,10 @@ export function showExerciseSummary(exerciseName, clientId = null) {
|
||||
|
||||
if (!s.days) {
|
||||
showModal(`
|
||||
<div class="modal-content">
|
||||
<div class="modal-header"><span class="modal-title">${escapeHtml(exerciseName)}</span><button class="btn-icon" onclick="closeModal()">✕</button></div>
|
||||
<div class="history-hint" style="margin:8px 0">Нет завершённых тренировок с этим упражнением.</div>
|
||||
</div>
|
||||
`);
|
||||
return;
|
||||
}
|
||||
@@ -32,6 +34,7 @@ export function showExerciseSummary(exerciseName, clientId = null) {
|
||||
).join('') || '<div class="history-hint">Пока нет данных по соседним упражнениям.</div>';
|
||||
|
||||
showModal(`
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<span class="modal-title">📋 ${escapeHtml(exerciseName)}</span>
|
||||
<button class="btn-icon" onclick="closeModal()">✕</button>
|
||||
@@ -62,6 +65,7 @@ export function showExerciseSummary(exerciseName, clientId = null) {
|
||||
<button class="btn btn-small btn-secondary" data-ex="${escapeHtml(exerciseName)}"
|
||||
onclick="EM.showChartFrom(this)">📈 График</button>
|
||||
</div>
|
||||
</div>
|
||||
`);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user