import React from 'react';
export default function TrendChart({ trendSeries = [] }) {
if (trendSeries.length < 2) {
return (
Für den Trend werden mindestens 2 Assessments benötigt.
);
}
const width = 760;
const height = 280;
const left = 50;
const right = 20;
const top = 16;
const bottom = 52;
const values = trendSeries.map((entry) => entry.totalPoints);
const minValue = Math.min(...values);
const maxValue = Math.max(...values);
const range = maxValue - minValue || 1;
const innerWidth = width - left - right;
const innerHeight = height - top - bottom;
const points = trendSeries.map((entry, index) => {
const x = left + (index / (trendSeries.length - 1)) * innerWidth;
const normalized = (entry.totalPoints - minValue) / range;
const y = top + innerHeight - normalized * innerHeight;
return { ...entry, x, y };
});
const path = points.map((point, index) => `${index === 0 ? 'M' : 'L'}${point.x},${point.y}`).join(' ');
return (
Trend (Gesamtpunkte)
);
}