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

@@ -113,6 +113,7 @@ const MedPlanAssistant = () => {
displayedDays={displayedDays}
yAxisMin={yAxisMin}
yAxisMax={yAxisMax}
days={days}
t={t}
/>
</div>

View File

@@ -107,7 +107,7 @@ const DaySchedule: React.FC<DayScheduleProps> = ({
)}
</Button>
<CardTitle className="text-lg">
{day.isTemplate ? t('regularPlan') : t('deviatingPlan')}
{day.isTemplate ? t('regularPlan') : t('alternativePlan')}
</CardTitle>
<Badge variant="secondary" className="text-xs">
{t('day')} {dayIndex + 1}

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',

View File

@@ -104,7 +104,7 @@ export const getDefaultState = (): AppState => ({
chartView: 'damph',
yAxisMin: '8',
yAxisMax: '13',
simulationDays: '4',
displayedDays: '3',
simulationDays: '5',
displayedDays: '5',
}
});

View File

@@ -45,6 +45,9 @@ export const de = {
tickNoon: "Mittag",
refLineRegularPlan: "Regulärer Plan",
refLineDeviatingPlan: "Abweichung vom Plan",
refLineNoDeviation: "Keine Abweichung",
refLineRecovering: "Erholung",
refLineIrregularIntake: "Irreguläre Einnahme",
refLineDayX: "Tag {{x}}",
refLineMin: "Min",
refLineMax: "Max",
@@ -98,6 +101,7 @@ export const de = {
// Day-based schedule
regularPlan: "Regulärer Plan",
deviatingPlan: "Abweichung vom Plan",
alternativePlan: "Alternativer Plan",
regularPlanOverlay: "Regulär",
dayNumber: "Tag {{number}}",
cloneDay: "Tag klonen",

View File

@@ -45,6 +45,9 @@ export const en = {
tickNoon: "Noon",
refLineRegularPlan: "Regular Plan",
refLineDeviatingPlan: "Deviation from Plan",
refLineNoDeviation: "No Deviation",
refLineRecovering: "Recovering",
refLineIrregularIntake: "Irregular Intake",
refLineDayX: "Day {{x}}",
refLineMin: "Min",
refLineMax: "Max",
@@ -107,6 +110,7 @@ export const en = {
// Day-based schedule
regularPlan: "Regular Plan",
deviatingPlan: "Deviation from Plan",
alternativePlan: "Alternative Plan",
regularPlanOverlay: "Regular",
dayNumber: "Day {{number}}",
cloneDay: "Clone day",