feat(dashboard): даты по всей оси X, легенда вниз, крупнее шрифты, запоминаемый выбор упражнения, сводка по упражнению с синергичными
This commit is contained in:
@@ -27,7 +27,7 @@ export function drawExerciseProgress(canvas, exerciseName) {
|
||||
|
||||
const maxWeight = Math.max(...days.map(d => d.max), 1);
|
||||
|
||||
const padding = { top: 26, right: 14, bottom: 34, left: 44 };
|
||||
const padding = { top: 14, right: 14, bottom: 58, left: 44 };
|
||||
const chartW = width - padding.left - padding.right;
|
||||
const chartH = height - padding.top - padding.bottom;
|
||||
|
||||
@@ -88,34 +88,28 @@ export function drawExerciseProgress(canvas, exerciseName) {
|
||||
ctx.stroke();
|
||||
if (n <= 10 || i >= n - 4 || classes[i] !== 'flat') {
|
||||
ctx.fillStyle = COLORS[classes[i]];
|
||||
ctx.font = 'bold 11px sans-serif';
|
||||
ctx.font = 'bold 12px sans-serif';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.fillText(`${d.max}×${d.topReps || ''}`, px, y(d.max) - 7);
|
||||
ctx.fillText(`${d.max}×${d.topReps || ''}`, px, y(d.max) - 8);
|
||||
}
|
||||
|
||||
// Количество подходов (выносливость)
|
||||
if (n <= 12 || i % 2 === 0) {
|
||||
ctx.fillStyle = '#b0b0b0';
|
||||
ctx.font = '9px sans-serif';
|
||||
// Дата под каждой точкой оси X и количество подходов (выносливость)
|
||||
if (n <= 10 || i % 2 === 0) {
|
||||
ctx.fillStyle = '#d5d5d5';
|
||||
ctx.font = '10px sans-serif';
|
||||
ctx.textAlign = 'center';
|
||||
ctx.fillText('×' + d.sets.length, px, height - padding.bottom + 12);
|
||||
ctx.fillText(formatShortDate(d.date.toISOString()), px, height - padding.bottom + 15);
|
||||
ctx.fillStyle = '#b0b0b0';
|
||||
ctx.font = '10px sans-serif';
|
||||
ctx.fillText('×' + d.sets.length, px, height - padding.bottom + 29);
|
||||
}
|
||||
});
|
||||
|
||||
// Даты первой и последней тренировки
|
||||
ctx.fillStyle = '#b0b0b0';
|
||||
ctx.font = '10px sans-serif';
|
||||
ctx.textAlign = 'left';
|
||||
ctx.fillText(formatShortDate(days[0].date.toISOString()), padding.left, height - 6);
|
||||
if (n > 1) {
|
||||
ctx.textAlign = 'right';
|
||||
ctx.fillText(formatShortDate(days[n - 1].date.toISOString()), width - padding.right, height - 6);
|
||||
}
|
||||
|
||||
// Легенда — внизу, под датами
|
||||
drawLegend(ctx, width, [
|
||||
{ color: '#3ddc55', label: 'рабочий максимум: зелёный — прогресс, красный — откат' },
|
||||
{ color: 'rgba(199, 146, 255, 0.55)', label: 'тусклая точка = подход (размер = повторы)' },
|
||||
]);
|
||||
], height - 8);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -291,8 +285,8 @@ function drawGridAndAxes(ctx, pad, cw, ch, maxY, maxXAxisLabel, yAxisLabel) {
|
||||
ctx.stroke();
|
||||
|
||||
// Подписи Y
|
||||
ctx.fillStyle = '#b0b0b0';
|
||||
ctx.font = '10px sans-serif';
|
||||
ctx.fillStyle = '#c9c9c9';
|
||||
ctx.font = '11px sans-serif';
|
||||
ctx.textAlign = 'right';
|
||||
for(let i=0; i<=4; i++) {
|
||||
const val = (maxY * i / 4).toFixed(0);
|
||||
@@ -339,15 +333,16 @@ function drawLineChart(ctx, data, pad, cw, ch, maxY, getValueFn, color, lineWidt
|
||||
}
|
||||
|
||||
|
||||
function drawLegend(ctx, width, items) {
|
||||
ctx.font = '10px sans-serif';
|
||||
function drawLegend(ctx, width, items, y) {
|
||||
// y — базовая линия текста (легенда внизу); квадрат чуть выше текста
|
||||
ctx.font = '11px sans-serif';
|
||||
ctx.textAlign = 'left';
|
||||
let xOffset = 10;
|
||||
items.forEach(item => {
|
||||
ctx.fillStyle = item.color;
|
||||
ctx.fillRect(xOffset, 10, 10, 10);
|
||||
ctx.fillRect(xOffset, y - 9, 10, 10);
|
||||
ctx.fillStyle = '#fff';
|
||||
ctx.fillText(item.label, xOffset + 15, 19);
|
||||
ctx.fillText(item.label, xOffset + 15, y);
|
||||
xOffset += ctx.measureText(item.label).width + 30;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user