Update pin feature for chart

This commit is contained in:
2026-01-16 15:25:01 +00:00
parent 678bd6c7b6
commit dbfaf26591
5 changed files with 40 additions and 21 deletions

View File

@@ -10,7 +10,7 @@
*/ */
import React from 'react'; import React from 'react';
import { GitBranch } from 'lucide-react'; import { GitBranch, Pin, PinOff } from 'lucide-react';
// Components // Components
import DaySchedule from './components/day-schedule'; import DaySchedule from './components/day-schedule';
@@ -111,8 +111,10 @@ const MedPlanAssistant = () => {
<div className="grid grid-cols-1 xl:grid-cols-2 gap-6"> <div className="grid grid-cols-1 xl:grid-cols-2 gap-6">
{/* Both Columns - Chart */} {/* Both Columns - Chart */}
<div className="xl:col-span-2 bg-card p-6 rounded-lg border min-h-[600px] flex flex-col"> <div className={`xl:col-span-2 bg-card p-6 rounded-lg border min-h-[600px] flex flex-col ${uiSettings.stickyChart ? 'sticky top-2 z-30 shadow-lg' : ''}`}
<div className="flex justify-center gap-2 mb-4"> style={uiSettings.stickyChart ? { borderColor: 'hsl(var(--primary))' } : {}}>
<div className="flex justify-between items-center mb-4">
<div className="flex justify-center gap-2">
<Button <Button
onClick={() => updateUiSetting('chartView', 'damph')} onClick={() => updateUiSetting('chartView', 'damph')}
variant={chartView === 'damph' ? 'default' : 'secondary'} variant={chartView === 'damph' ? 'default' : 'secondary'}
@@ -132,6 +134,15 @@ const MedPlanAssistant = () => {
{t('both')} {t('both')}
</Button> </Button>
</div> </div>
<Button
onClick={() => updateUiSetting('stickyChart', !uiSettings.stickyChart)}
variant={uiSettings.stickyChart ? 'default' : 'outline'}
size="sm"
title={uiSettings.stickyChart ? t('unpinChart') : t('pinChart')}
>
{uiSettings.stickyChart ? <Pin size={16} /> : <PinOff size={16} />}
</Button>
</div>
<SimulationChart <SimulationChart
combinedProfile={combinedProfile} combinedProfile={combinedProfile}

View File

@@ -218,12 +218,12 @@ const FormNumericInput = React.forwardRef<HTMLInputElement, NumericInputProps>(
</div> </div>
{unit && <span className="text-sm text-muted-foreground whitespace-nowrap">{unit}</span>} {unit && <span className="text-sm text-muted-foreground whitespace-nowrap">{unit}</span>}
{hasError && isFocused && errorMessage && ( {hasError && isFocused && errorMessage && (
<div className="absolute top-full left-0 mt-1 z-50 w-64 bg-destructive text-destructive-foreground text-xs p-2 rounded-md shadow-lg"> <div className="absolute top-full left-0 mt-1 z-25 w-64 bg-destructive text-destructive-foreground text-xs p-2 rounded-md shadow-lg">
{errorMessage} {errorMessage}
</div> </div>
)} )}
{hasWarning && isFocused && warningMessage && ( {hasWarning && isFocused && warningMessage && (
<div className="absolute top-full left-0 mt-1 z-50 w-48 bg-yellow-500 text-white text-xs p-2 rounded-md shadow-lg"> <div className="absolute top-full left-0 mt-1 z-25 w-48 bg-yellow-500 text-white text-xs p-2 rounded-md shadow-lg">
{warningMessage} {warningMessage}
</div> </div>
)} )}

View File

@@ -64,6 +64,7 @@ export interface UiSettings {
displayedDays: string; displayedDays: string;
showDayReferenceLines?: boolean; showDayReferenceLines?: boolean;
showTherapeuticRange?: boolean; showTherapeuticRange?: boolean;
stickyChart: boolean;
} }
export interface AppState { export interface AppState {
@@ -133,5 +134,6 @@ export const getDefaultState = (): AppState => ({
simulationDays: '5', simulationDays: '5',
displayedDays: '2', displayedDays: '2',
showTherapeuticRange: true, showTherapeuticRange: true,
stickyChart: false,
} }
}); });

View File

@@ -55,6 +55,9 @@ export const de = {
refLineDayShort: "T{{x}}", refLineDayShort: "T{{x}}",
refLineMin: "Min", refLineMin: "Min",
refLineMax: "Max", refLineMax: "Max",
pinChart: "Diagramm oben fixieren",
unpinChart: "Diagramm freigeben",
stickyChartTooltip: "Diagramm beim Scrollen durch die Einstellungen sichtbar halten, um Änderungen in Echtzeit zu sehen. Standard: aus.",
tooltipHour: "Stunde", tooltipHour: "Stunde",
// Settings // Settings

View File

@@ -49,12 +49,15 @@ export const en = {
refLineIrregularIntake: "Irregular", refLineIrregularIntake: "Irregular",
refLineDayX: "D{{x}}", refLineDayX: "D{{x}}",
refLineRegularPlanShort: "(Reg.)", refLineRegularPlanShort: "(Reg.)",
refLineNoDeviationShort: "(Reg.)", refLineNoDeviationShort: "(Reg.)", // currently the same as above (day# > 1 with curve identical to day1 / regular plan)
refLineRecoveringShort: "(Rec.)", refLineRecoveringShort: "(Rec.)",
refLineIrregularIntakeShort: "(Ireg.)", refLineIrregularIntakeShort: "(Ireg.)",
refLineDayShort: "D{{x}}", refLineDayShort: "D{{x}}",
refLineMin: "Min", refLineMin: "Min",
refLineMax: "Max", refLineMax: "Max",
pinChart: "Pin chart to top",
unpinChart: "Unpin chart",
stickyChartTooltip: "Keep chart visible while scrolling through settings for real-time feedback. Default: off.",
// Settings // Settings
diagramSettings: "Diagram Settings", diagramSettings: "Diagram Settings",