Update improved legend labels for tablate curve to match opacity of the curve
This commit is contained in:
@@ -114,7 +114,7 @@ const Settings = ({
|
|||||||
increment={1}
|
increment={1}
|
||||||
min={3}
|
min={3}
|
||||||
max={7}
|
max={7}
|
||||||
unit={t('days')}
|
unit={t('unitDays')}
|
||||||
required={true}
|
required={true}
|
||||||
errorMessage={t('errorNumberRequired')}
|
errorMessage={t('errorNumberRequired')}
|
||||||
/>
|
/>
|
||||||
@@ -128,7 +128,7 @@ const Settings = ({
|
|||||||
increment={1}
|
increment={1}
|
||||||
min={1}
|
min={1}
|
||||||
max={parseInt(simulationDays, 10) || 3}
|
max={parseInt(simulationDays, 10) || 3}
|
||||||
unit={t('days')}
|
unit={t('unitDays')}
|
||||||
required={true}
|
required={true}
|
||||||
errorMessage={t('errorNumberRequired')}
|
errorMessage={t('errorNumberRequired')}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -183,6 +183,11 @@ const SimulationChart = ({
|
|||||||
align="left"
|
align="left"
|
||||||
height={36}
|
height={36}
|
||||||
wrapperStyle={{ paddingLeft: 0 }}
|
wrapperStyle={{ paddingLeft: 0 }}
|
||||||
|
formatter={(value: string) => {
|
||||||
|
// Apply lighter color to template overlay entries in legend
|
||||||
|
const isTemplate = value.includes(t('regularPlanOverlay'));
|
||||||
|
return <span style={{ opacity: isTemplate ? 0.5 : 1 }}>{value}</span>;
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
{/* Invisible lines just to show in legend */}
|
{/* Invisible lines just to show in legend */}
|
||||||
{(chartView === 'damph' || chartView === 'both') && (
|
{(chartView === 'damph' || chartView === 'both') && (
|
||||||
@@ -206,7 +211,7 @@ const SimulationChart = ({
|
|||||||
strokeOpacity={0}
|
strokeOpacity={0}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{templateProfile && (chartView === 'damph' || chartView === 'both') && (
|
{templateProfile && daysWithDeviations.size > 0 && (chartView === 'damph' || chartView === 'both') && (
|
||||||
<Line
|
<Line
|
||||||
dataKey="templateDamph"
|
dataKey="templateDamph"
|
||||||
name={`${t('dAmphetamine')} (${t('regularPlanOverlay')})`}
|
name={`${t('dAmphetamine')} (${t('regularPlanOverlay')})`}
|
||||||
@@ -215,9 +220,10 @@ const SimulationChart = ({
|
|||||||
strokeDasharray="3 3"
|
strokeDasharray="3 3"
|
||||||
dot={false}
|
dot={false}
|
||||||
strokeOpacity={0}
|
strokeOpacity={0}
|
||||||
|
opacity={0.5}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{templateProfile && (chartView === 'ldx' || chartView === 'both') && (
|
{templateProfile && daysWithDeviations.size > 0 && (chartView === 'ldx' || chartView === 'both') && (
|
||||||
<Line
|
<Line
|
||||||
dataKey="templateLdx"
|
dataKey="templateLdx"
|
||||||
name={`${t('lisdexamfetamine')} (${t('regularPlanOverlay')})`}
|
name={`${t('lisdexamfetamine')} (${t('regularPlanOverlay')})`}
|
||||||
@@ -226,6 +232,7 @@ const SimulationChart = ({
|
|||||||
strokeDasharray="3 3"
|
strokeDasharray="3 3"
|
||||||
dot={false}
|
dot={false}
|
||||||
strokeOpacity={0}
|
strokeOpacity={0}
|
||||||
|
opacity={0.5}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</LineChart>
|
</LineChart>
|
||||||
@@ -294,11 +301,50 @@ const SimulationChart = ({
|
|||||||
tickCount={20}
|
tickCount={20}
|
||||||
/>
|
/>
|
||||||
<Tooltip
|
<Tooltip
|
||||||
formatter={(value: any, name) => [`${typeof value === 'number' ? value.toFixed(1) : value} ${t('ngml')}`, name]}
|
content={({ active, payload, label }) => {
|
||||||
labelFormatter={(label, payload) => {
|
if (!active || !payload || payload.length === 0) return null;
|
||||||
|
|
||||||
// Extract timeHours from the payload data point
|
// Extract timeHours from the payload data point
|
||||||
const timeHours = payload?.[0]?.payload?.timeHours ?? label;
|
const timeHours = payload[0]?.payload?.timeHours ?? label;
|
||||||
return `${t('hour').replace('h', 'Hour')}: ${timeHours}${t('hour')}`;
|
const h = typeof timeHours === 'number' ? timeHours : parseFloat(timeHours);
|
||||||
|
|
||||||
|
// Format time to match x-axis format
|
||||||
|
let timeLabel: string;
|
||||||
|
if (showDayTimeOnXAxis === '24h') {
|
||||||
|
timeLabel = `${h % 24}${t('unitHour')}`;
|
||||||
|
} else if (showDayTimeOnXAxis === '12h') {
|
||||||
|
const hour12 = h % 24;
|
||||||
|
if (hour12 === 12) {
|
||||||
|
timeLabel = t('tickNoon');
|
||||||
|
} else {
|
||||||
|
const displayHour = hour12 === 0 ? 12 : hour12 > 12 ? hour12 - 12 : hour12;
|
||||||
|
const period = hour12 < 12 ? 'a' : 'p';
|
||||||
|
timeLabel = `${displayHour}${period}`;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
timeLabel = `${h}${t('unitHour')}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="recharts-default-tooltip" style={{ margin: 0, padding: 10, backgroundColor: 'rgb(255, 255, 255)', border: '1px solid rgb(204, 204, 204)', whiteSpace: 'nowrap' }}>
|
||||||
|
<p className="recharts-tooltip-label" style={{ margin: 0 }}>{t('time')}: {timeLabel}</p>
|
||||||
|
<ul className="recharts-tooltip-item-list" style={{ padding: 0, margin: 0 }}>
|
||||||
|
{payload.map((entry: any, index: number) => {
|
||||||
|
const isTemplate = entry.name?.includes(t('regularPlanOverlay'));
|
||||||
|
const opacity = isTemplate ? 0.5 : 1;
|
||||||
|
const value = typeof entry.value === 'number' ? entry.value.toFixed(1) : entry.value;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<li key={`item-${index}`} className="recharts-tooltip-item" style={{ display: 'block', paddingTop: 4, paddingBottom: 4, color: entry.color, opacity }}>
|
||||||
|
<span className="recharts-tooltip-item-name">{entry.name}</span>
|
||||||
|
<span className="recharts-tooltip-item-separator">: </span>
|
||||||
|
<span className="recharts-tooltip-item-value">{value} {t('unitNgml')}</span>
|
||||||
|
</li>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
wrapperStyle={{ pointerEvents: 'none', zIndex: 200 }}
|
wrapperStyle={{ pointerEvents: 'none', zIndex: 200 }}
|
||||||
allowEscapeViewBox={{ x: false, y: false }}
|
allowEscapeViewBox={{ x: false, y: false }}
|
||||||
@@ -391,7 +437,7 @@ const SimulationChart = ({
|
|||||||
<Line
|
<Line
|
||||||
type="monotone"
|
type="monotone"
|
||||||
dataKey="templateDamph"
|
dataKey="templateDamph"
|
||||||
name={`${t('dAmphetamine')} (${t('regularPlan')} ${t('continuation')})`}
|
name={`${t('dAmphetamine')} (${t('regularPlanOverlay')})`}
|
||||||
stroke={CHART_COLORS.idealDamph}
|
stroke={CHART_COLORS.idealDamph}
|
||||||
strokeWidth={2}
|
strokeWidth={2}
|
||||||
strokeDasharray="3 3"
|
strokeDasharray="3 3"
|
||||||
@@ -406,7 +452,7 @@ const SimulationChart = ({
|
|||||||
<Line
|
<Line
|
||||||
type="monotone"
|
type="monotone"
|
||||||
dataKey="templateLdx"
|
dataKey="templateLdx"
|
||||||
name={`${t('lisdexamfetamine')} (${t('regularPlan')} ${t('continuation')})`}
|
name={`${t('lisdexamfetamine')} (${t('regularPlanOverlay')})`}
|
||||||
stroke={CHART_COLORS.idealLdx}
|
stroke={CHART_COLORS.idealLdx}
|
||||||
strokeWidth={1.5}
|
strokeWidth={1.5}
|
||||||
strokeDasharray="3 3"
|
strokeDasharray="3 3"
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ export const de = {
|
|||||||
refLineDayX: "Tag {{x}}",
|
refLineDayX: "Tag {{x}}",
|
||||||
refLineMin: "Min",
|
refLineMin: "Min",
|
||||||
refLineMax: "Max",
|
refLineMax: "Max",
|
||||||
|
tooltipHour: "Stunde",
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
diagramSettings: "Diagramm-Einstellungen",
|
diagramSettings: "Diagramm-Einstellungen",
|
||||||
@@ -61,7 +62,6 @@ export const de = {
|
|||||||
showTemplateDayInChart: "Regulären Plan in abweichenden Tagen zusätzlich einblenden",
|
showTemplateDayInChart: "Regulären Plan in abweichenden Tagen zusätzlich einblenden",
|
||||||
showDayReferenceLines: "Tagestrenner anzeigen",
|
showDayReferenceLines: "Tagestrenner anzeigen",
|
||||||
simulationDuration: "Simulationsdauer",
|
simulationDuration: "Simulationsdauer",
|
||||||
days: "Tage",
|
|
||||||
displayedDays: "Sichtbare Tage (im Fokus)",
|
displayedDays: "Sichtbare Tage (im Fokus)",
|
||||||
yAxisRange: "Y-Achsen-Bereich (Zoom)",
|
yAxisRange: "Y-Achsen-Bereich (Zoom)",
|
||||||
yAxisRangeAutoButton: "A",
|
yAxisRangeAutoButton: "A",
|
||||||
@@ -70,7 +70,6 @@ export const de = {
|
|||||||
therapeuticRange: "Therapeutischer Bereich (Referenzlinien)",
|
therapeuticRange: "Therapeutischer Bereich (Referenzlinien)",
|
||||||
dAmphetamineParameters: "d-Amphetamin Parameter",
|
dAmphetamineParameters: "d-Amphetamin Parameter",
|
||||||
halfLife: "Halbwertszeit",
|
halfLife: "Halbwertszeit",
|
||||||
hours: "h",
|
|
||||||
lisdexamfetamineParameters: "Lisdexamfetamin Parameter",
|
lisdexamfetamineParameters: "Lisdexamfetamin Parameter",
|
||||||
conversionHalfLife: "Umwandlungs-Halbwertszeit",
|
conversionHalfLife: "Umwandlungs-Halbwertszeit",
|
||||||
absorptionRate: "Absorptionsrate",
|
absorptionRate: "Absorptionsrate",
|
||||||
@@ -78,8 +77,10 @@ export const de = {
|
|||||||
resetAllSettings: "Alle Einstellungen zurücksetzen",
|
resetAllSettings: "Alle Einstellungen zurücksetzen",
|
||||||
|
|
||||||
// Units
|
// Units
|
||||||
mg: "mg",
|
unitMg: "mg",
|
||||||
ngml: "ng/ml",
|
unitNgml: "ng/ml",
|
||||||
|
unitHour: "h",
|
||||||
|
unitDays: "Tage",
|
||||||
|
|
||||||
// Reset confirmation
|
// Reset confirmation
|
||||||
resetConfirmation: "Bist du sicher, dass du alle Einstellungen auf die Standardwerte zurücksetzen möchtest? Dies kann nicht rückgängig gemacht werden.",
|
resetConfirmation: "Bist du sicher, dass du alle Einstellungen auf die Standardwerte zurücksetzen möchtest? Dies kann nicht rückgängig gemacht werden.",
|
||||||
@@ -97,7 +98,7 @@ export const de = {
|
|||||||
// Day-based schedule
|
// Day-based schedule
|
||||||
regularPlan: "Regulärer Plan",
|
regularPlan: "Regulärer Plan",
|
||||||
deviatingPlan: "Abweichung vom Plan",
|
deviatingPlan: "Abweichung vom Plan",
|
||||||
regularPlanOverlay: "Regulär",
|
regularPlanOverlay: "nach Plan",
|
||||||
dayNumber: "Tag {{number}}",
|
dayNumber: "Tag {{number}}",
|
||||||
cloneDay: "Tag klonen",
|
cloneDay: "Tag klonen",
|
||||||
addDay: "Tag hinzufügen",
|
addDay: "Tag hinzufügen",
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ export const en = {
|
|||||||
showTemplateDayInChart: "Overlay regular plan for deviating days",
|
showTemplateDayInChart: "Overlay regular plan for deviating days",
|
||||||
showDayReferenceLines: "Show day separators",
|
showDayReferenceLines: "Show day separators",
|
||||||
simulationDuration: "Simulation Duration",
|
simulationDuration: "Simulation Duration",
|
||||||
days: "Days",
|
|
||||||
displayedDays: "Visible Days (in Focus)",
|
displayedDays: "Visible Days (in Focus)",
|
||||||
yAxisRange: "Y-Axis Range (Zoom)",
|
yAxisRange: "Y-Axis Range (Zoom)",
|
||||||
yAxisRangeAutoButton: "A",
|
yAxisRangeAutoButton: "A",
|
||||||
@@ -70,7 +69,6 @@ export const en = {
|
|||||||
therapeuticRange: "Therapeutic Range (Reference Lines)",
|
therapeuticRange: "Therapeutic Range (Reference Lines)",
|
||||||
dAmphetamineParameters: "d-Amphetamine Parameters",
|
dAmphetamineParameters: "d-Amphetamine Parameters",
|
||||||
halfLife: "Half-life",
|
halfLife: "Half-life",
|
||||||
hours: "h",
|
|
||||||
lisdexamfetamineParameters: "Lisdexamfetamine Parameters",
|
lisdexamfetamineParameters: "Lisdexamfetamine Parameters",
|
||||||
conversionHalfLife: "Conversion Half-life",
|
conversionHalfLife: "Conversion Half-life",
|
||||||
absorptionRate: "Absorption Rate",
|
absorptionRate: "Absorption Rate",
|
||||||
@@ -78,8 +76,10 @@ export const en = {
|
|||||||
resetAllSettings: "Reset All Settings",
|
resetAllSettings: "Reset All Settings",
|
||||||
|
|
||||||
// Units
|
// Units
|
||||||
mg: "mg",
|
unitMg: "mg",
|
||||||
ngml: "ng/ml",
|
unitNgml: "ng/ml",
|
||||||
|
unitHour: "h",
|
||||||
|
unitDays: "Days",
|
||||||
|
|
||||||
// Reset confirmation
|
// Reset confirmation
|
||||||
resetConfirmation: "Are you sure you want to reset all settings to default values? This cannot be undone.",
|
resetConfirmation: "Are you sure you want to reset all settings to default values? This cannot be undone.",
|
||||||
@@ -107,7 +107,7 @@ export const en = {
|
|||||||
// Day-based schedule
|
// Day-based schedule
|
||||||
regularPlan: "Regular Plan",
|
regularPlan: "Regular Plan",
|
||||||
deviatingPlan: "Deviation from Plan",
|
deviatingPlan: "Deviation from Plan",
|
||||||
regularPlanOverlay: "Regular",
|
regularPlanOverlay: "as planned",
|
||||||
dayNumber: "Day {{number}}",
|
dayNumber: "Day {{number}}",
|
||||||
cloneDay: "Clone day",
|
cloneDay: "Clone day",
|
||||||
addDay: "Add day",
|
addDay: "Add day",
|
||||||
|
|||||||
Reference in New Issue
Block a user