feat(frontend): redesign race dashboard
Some checks failed
CI / build-and-test (pull_request) Has been cancelled
Some checks failed
CI / build-and-test (pull_request) Has been cancelled
This commit is contained in:
@@ -55,16 +55,38 @@ export function PaceTrendChart(props: PaceTrendChartProps): JSX.Element {
|
||||
.join(" ");
|
||||
|
||||
const last = series[series.length - 1]!;
|
||||
const best = series.reduce((currentBest, item) => (item.minutes < currentBest.minutes ? item : currentBest), series[0]!);
|
||||
const dotPoints = series.map((s, i) => {
|
||||
const x = pad + (n === 1 ? innerW / 2 : (i / (n - 1)) * innerW);
|
||||
const norm = (maxM - s.minutes) / range;
|
||||
const y = pad + (1 - norm) * innerH;
|
||||
return { x, y, id: s.race.id };
|
||||
});
|
||||
|
||||
return (
|
||||
<div className="pace-chart">
|
||||
<svg className="pace-chart__svg" viewBox={`0 0 ${w} ${h}`} role="img" aria-label="Динамика времени на дистанции">
|
||||
<line className="pace-chart__grid-line" x1={pad} y1={pad} x2={w - pad} y2={pad} />
|
||||
<line className="pace-chart__grid-line" x1={pad} y1={h - pad} x2={w - pad} y2={h - pad} />
|
||||
<polyline className="pace-chart__line" fill="none" points={points} />
|
||||
{dotPoints.map((point, index) => (
|
||||
<circle
|
||||
key={point.id}
|
||||
className={index === dotPoints.length - 1 ? "pace-chart__dot pace-chart__dot--last" : "pace-chart__dot"}
|
||||
cx={point.x}
|
||||
cy={point.y}
|
||||
r="1.6"
|
||||
/>
|
||||
))}
|
||||
</svg>
|
||||
<p className="pace-chart__caption">
|
||||
Последний пункт: {formatRaceDate(last.race.date)} — {last.race.finishTime} (
|
||||
{last.minutes.toFixed(1)} мин)
|
||||
</p>
|
||||
<div className="pace-chart__stats">
|
||||
<p className="pace-chart__caption">
|
||||
Последний: {formatRaceDate(last.race.date)} · {last.race.finishTime} · {last.minutes.toFixed(1)} мин
|
||||
</p>
|
||||
<p className="pace-chart__caption pace-chart__caption--best">
|
||||
Лучший: {formatRaceDate(best.race.date)} · {best.race.finishTime} · {best.minutes.toFixed(1)} мин
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user