Update day schedule and simulation chart labels, enhance defaults

This commit is contained in:
2025-12-04 02:03:37 +00:00
parent d64b9eabfa
commit 6b9d8cdf49
6 changed files with 36 additions and 5 deletions

View File

@@ -46,6 +46,7 @@ const SimulationChart = ({
displayedDays,
yAxisMin,
yAxisMax,
days,
t
}: any) => {
const totalHours = (parseInt(simulationDays, 10) || 3) * 24;
@@ -113,6 +114,28 @@ const SimulationChart = ({
return deviatingDays;
}, [combinedProfile, templateProfile, simulationDays]);
// Determine label for each day's reference line
const getDayLabel = React.useCallback((dayNumber: number) => {
if (dayNumber === 1) return t('refLineRegularPlan');
// Check if this day has an actual schedule entry (not auto-filled)
const hasSchedule = days && days.length >= dayNumber;
// Check if this day deviates from template
const hasDeviation = daysWithDeviations.has(dayNumber);
if (!hasDeviation) {
// Matches template
return t('refLineNoDeviation');
} else if (!hasSchedule) {
// Deviates but no schedule = recovering
return t('refLineRecovering');
} else {
// Has deviation and has schedule = actual irregular intake
return t('refLineIrregularIntake');
}
}, [days, daysWithDeviations, t]);
// Merge all profiles into a single dataset for proper tooltip synchronization
const mergedData = React.useMemo(() => {
const dataMap = new Map();
@@ -358,9 +381,8 @@ const SimulationChart = ({
<ReferenceLine
key={`day-${day+1}`}
x={24 * (day+1)}
// TODO instead of refLineDeviatingPlan show refLineRegularPlan in case there are no deviations (primary curve for the given day matches the template)
label={{
value: (day === 0 ? t('refLineRegularPlan') : t('refLineDeviatingPlan')) + ' (' + t('refLineDayX', { x: day+1 }) + ')',
value: t('refLineDayX', { x: day+1 }) + '' + getDayLabel(day + 1),
position: 'insideTopRight',
style: {
fontSize: '0.75rem',