fix(chart): превью в гостевом режиме, контрастнее цвета и толще линии графиков
This commit is contained in:
@@ -31,7 +31,11 @@
|
||||
<div id="modal-container"></div>
|
||||
<script src="demo-seed.js"></script>
|
||||
<script>
|
||||
// Превью всегда работает на свежем датасете
|
||||
// Превью всегда работает в гостевом режиме на свежем датасете:
|
||||
// если в этом браузере есть сохранённый вход, данные читались бы из пустого
|
||||
// пользовательского ключа и график показал бы «нет завершённых тренировок».
|
||||
localStorage.removeItem('gym_auth_token');
|
||||
localStorage.removeItem('gym_auth_user');
|
||||
localStorage.setItem('gym_tracker_v7_guest', JSON.stringify(window.GYM_DEMO_SEED));
|
||||
</script>
|
||||
<script type="module">
|
||||
|
||||
@@ -23,6 +23,11 @@ localStorage.setItem('gym_api_base', 'http://127.0.0.1:8000');
|
||||
// Демо-датасет v4 (прогрессия жима, пиратка штанги, суперсет, дропсет): пересев при смене версии
|
||||
if (localStorage.getItem('gym_demo_seed') !== 'v4') {
|
||||
localStorage.setItem('gym_tracker_v7_guest', JSON.stringify(window.GYM_DEMO_SEED));
|
||||
// если уже выполнен вход — обновить и пользовательский ключ (в него мигрировали старые данные)
|
||||
try {
|
||||
const u = JSON.parse(localStorage.getItem('gym_auth_user'));
|
||||
if (u && u.id) localStorage.setItem('gym_tracker_v7_user_' + u.id, JSON.stringify(window.GYM_DEMO_SEED));
|
||||
} catch (e) { /* гостевой режим */ }
|
||||
localStorage.setItem('gym_demo_seed', 'v4');
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -76,7 +76,7 @@ export function showChartDialog(exerciseName, clientId = null) {
|
||||
// Вершины: крупная точка + подпись «вес×повт.» с цветом прогресса
|
||||
const showLabel = i => n <= 10 || i >= n - 5 || 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="4"></circle>` +
|
||||
`<circle class="chart-vert ${classes[i]}" cx="${x(i).toFixed(1)}" cy="${y(dayTop(p)).toFixed(1)}" r="5.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>`
|
||||
: '')
|
||||
|
||||
@@ -41,7 +41,7 @@ export function drawExerciseProgress(canvas, exerciseName) {
|
||||
|
||||
// Прогресс вершины относительно прошлой тренировки: вес выше — или тот же
|
||||
// вес и больше повторов => зелёный; меньше => красный; ровно => фиолетовый.
|
||||
const COLORS = { up: '#4caf50', down: '#e57373', flat: '#bb86fc' };
|
||||
const COLORS = { up: '#3ddc55', down: '#ff5a5a', flat: '#c792ff' };
|
||||
const cls = i => {
|
||||
if (i === 0) return 'flat';
|
||||
const a = days[i - 1], b = days[i];
|
||||
@@ -56,7 +56,7 @@ export function drawExerciseProgress(canvas, exerciseName) {
|
||||
// Линия рабочего максимума: отрезки окрашены по прогрессу конца отрезка
|
||||
for (let i = 1; i < n; i++) {
|
||||
ctx.strokeStyle = COLORS[classes[i]];
|
||||
ctx.lineWidth = 2.5;
|
||||
ctx.lineWidth = 4;
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x(i - 1), y(days[i - 1].max));
|
||||
ctx.lineTo(x(i), y(days[i].max));
|
||||
@@ -71,9 +71,9 @@ export function drawExerciseProgress(canvas, exerciseName) {
|
||||
const spread = below.length > 1 ? Math.min(11, chartW / (3 * n)) : 0;
|
||||
below.forEach((s, k) => {
|
||||
const dx = below.length > 1 ? -spread + (2 * spread * k) / (below.length - 1) : 0;
|
||||
const r = 1.8 + 2.4 * Math.min(1, s.reps / maxReps);
|
||||
const r = 2.2 + 2.8 * Math.min(1, s.reps / maxReps);
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = 'rgba(187, 134, 252, 0.35)';
|
||||
ctx.fillStyle = 'rgba(199, 146, 255, 0.55)';
|
||||
ctx.arc(px + dx, y(s.weight), r, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
});
|
||||
@@ -81,14 +81,14 @@ export function drawExerciseProgress(canvas, exerciseName) {
|
||||
// Вершина: рабочий максимум «вес × повторы» с цветом прогресса
|
||||
ctx.beginPath();
|
||||
ctx.fillStyle = COLORS[classes[i]];
|
||||
ctx.arc(px, y(d.max), 4.2, 0, Math.PI * 2);
|
||||
ctx.arc(px, y(d.max), 5.5, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
ctx.strokeStyle = '#ffffff';
|
||||
ctx.lineWidth = 1.2;
|
||||
ctx.stroke();
|
||||
if (n <= 10 || i >= n - 4 || classes[i] !== 'flat') {
|
||||
ctx.fillStyle = COLORS[classes[i]];
|
||||
ctx.font = 'bold 10px sans-serif';
|
||||
ctx.font = 'bold 11px sans-serif';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.fillText(`${d.max}×${d.topReps || ''}`, px, y(d.max) - 7);
|
||||
}
|
||||
@@ -113,8 +113,8 @@ export function drawExerciseProgress(canvas, exerciseName) {
|
||||
}
|
||||
|
||||
drawLegend(ctx, width, [
|
||||
{ color: '#4caf50', label: 'рабочий максимум: зелёный — прогресс, красный — откат' },
|
||||
{ color: 'rgba(187, 134, 252, 0.45)', label: 'тусклая точка = подход (размер = повторы)' },
|
||||
{ color: '#3ddc55', label: 'рабочий максимум: зелёный — прогресс, красный — откат' },
|
||||
{ color: 'rgba(199, 146, 255, 0.55)', label: 'тусклая точка = подход (размер = повторы)' },
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -138,20 +138,20 @@ textarea { resize: vertical; min-height: 60px; }
|
||||
.chart-axis { stroke: var(--border); stroke-width: 1; }
|
||||
.chart-label { font-size: 9px; fill: var(--text-secondary, #888); }
|
||||
/* Линия рабочего максимума и её вершины: цвет = прогресс относительно прошлого раза */
|
||||
.chart-seg { stroke-width: 2.5; stroke-linecap: round; }
|
||||
.chart-svg circle.chart-vert { stroke: var(--card-bg, #fff); stroke-width: 1.5; }
|
||||
.chart-seg.chart-up, .chart-svg circle.chart-vert.chart-up { stroke: #4caf50; }
|
||||
.chart-seg.chart-down, .chart-svg circle.chart-vert.chart-down { stroke: #e57373; }
|
||||
.chart-seg.chart-flat, .chart-svg circle.chart-vert.chart-flat { stroke: var(--accent); }
|
||||
.chart-svg circle.chart-vert.chart-up { fill: #4caf50; }
|
||||
.chart-svg circle.chart-vert.chart-down { fill: #e57373; }
|
||||
.chart-svg circle.chart-vert.chart-flat { fill: var(--accent); }
|
||||
.chart-vert-label { font-weight: 700; }
|
||||
.chart-vert-label.chart-up { fill: #4caf50; }
|
||||
.chart-vert-label.chart-down { fill: #e57373; }
|
||||
.chart-vert-label.chart-flat { fill: var(--accent); }
|
||||
.chart-up { color: #4caf50; }
|
||||
.chart-down { color: #e57373; }
|
||||
.chart-seg { stroke-width: 4; stroke-linecap: round; }
|
||||
.chart-svg circle.chart-vert { stroke: #fff; stroke-width: 2; }
|
||||
.chart-seg.chart-up, .chart-svg circle.chart-vert.chart-up { stroke: #3ddc55; }
|
||||
.chart-seg.chart-down, .chart-svg circle.chart-vert.chart-down { stroke: #ff5a5a; }
|
||||
.chart-seg.chart-flat, .chart-svg circle.chart-vert.chart-flat { stroke: #c792ff; }
|
||||
.chart-svg circle.chart-vert.chart-up { fill: #3ddc55; }
|
||||
.chart-svg circle.chart-vert.chart-down { fill: #ff5a5a; }
|
||||
.chart-svg circle.chart-vert.chart-flat { fill: #c792ff; }
|
||||
.chart-vert-label { font-weight: 700; font-size: 11px; }
|
||||
.chart-vert-label.chart-up { fill: #3ddc55; }
|
||||
.chart-vert-label.chart-down { fill: #ff5a5a; }
|
||||
.chart-vert-label.chart-flat { fill: #c792ff; }
|
||||
.chart-up { color: #3ddc55; }
|
||||
.chart-down { color: #ff5a5a; }
|
||||
.chart-sub { font-size: 0.72rem; color: var(--text-secondary, #888); }
|
||||
.chart-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
|
||||
.chart-row { display: flex; justify-content: space-between; gap: 8px; font-size: 0.78rem; }
|
||||
@@ -159,5 +159,5 @@ textarea { resize: vertical; min-height: 60px; }
|
||||
.chart-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.chart-sets { flex: 1; min-width: 0; text-align: right; color: var(--text-secondary, #888); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.chart-val { font-weight: 600; flex: 0 0 auto; }
|
||||
.chart-count { fill: var(--text-secondary, #888); font-size: 8.5px; }
|
||||
.chart-count { fill: #c9c9c9; font-size: 9.5px; }
|
||||
.chart-count-num { color: var(--accent); }
|
||||
|
||||
Reference in New Issue
Block a user