Update show regular plan overlay only if needed (per day)
This commit is contained in:
@@ -79,6 +79,40 @@ const SimulationChart = ({
|
|||||||
return [domainMin, domainMax];
|
return [domainMin, domainMax];
|
||||||
}, [yAxisMin, yAxisMax]);
|
}, [yAxisMin, yAxisMax]);
|
||||||
|
|
||||||
|
// Check which days have deviations (differ from template)
|
||||||
|
const daysWithDeviations = React.useMemo(() => {
|
||||||
|
if (!templateProfile || !combinedProfile) return new Set<number>();
|
||||||
|
|
||||||
|
const deviatingDays = new Set<number>();
|
||||||
|
const simDays = parseInt(simulationDays, 10) || 3;
|
||||||
|
|
||||||
|
// Check each day starting from day 2 (day 1 is always template)
|
||||||
|
for (let day = 2; day <= simDays; day++) {
|
||||||
|
const dayStartHour = (day - 1) * 24;
|
||||||
|
const dayEndHour = day * 24;
|
||||||
|
|
||||||
|
// Sample points in this day to check for differences
|
||||||
|
// Check every hour in the day
|
||||||
|
for (let hour = dayStartHour; hour < dayEndHour; hour++) {
|
||||||
|
const combinedPoint = combinedProfile.find((p: any) => Math.abs(p.timeHours - hour) < 0.1);
|
||||||
|
const templatePoint = templateProfile.find((p: any) => Math.abs(p.timeHours - hour) < 0.1);
|
||||||
|
|
||||||
|
if (combinedPoint && templatePoint) {
|
||||||
|
// Consider it different if values differ by more than 0.01 (tolerance for floating point)
|
||||||
|
const damphDiff = Math.abs(combinedPoint.damph - templatePoint.damph);
|
||||||
|
const ldxDiff = Math.abs(combinedPoint.ldx - templatePoint.ldx);
|
||||||
|
|
||||||
|
if (damphDiff > 0.01 || ldxDiff > 0.01) {
|
||||||
|
deviatingDays.add(day);
|
||||||
|
break; // Found deviation in this day, no need to check more hours
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return deviatingDays;
|
||||||
|
}, [combinedProfile, templateProfile, simulationDays]);
|
||||||
|
|
||||||
// Merge all profiles into a single dataset for proper tooltip synchronization
|
// Merge all profiles into a single dataset for proper tooltip synchronization
|
||||||
const mergedData = React.useMemo(() => {
|
const mergedData = React.useMemo(() => {
|
||||||
const dataMap = new Map();
|
const dataMap = new Map();
|
||||||
@@ -93,17 +127,23 @@ const SimulationChart = ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Add template profile data (regular plan only) if provided
|
// Add template profile data (regular plan only) if provided
|
||||||
|
// Only include points for days that have deviations
|
||||||
templateProfile?.forEach((point: any) => {
|
templateProfile?.forEach((point: any) => {
|
||||||
|
const pointDay = Math.ceil(point.timeHours / 24);
|
||||||
|
|
||||||
|
// Only include template data for days with deviations
|
||||||
|
if (daysWithDeviations.has(pointDay)) {
|
||||||
const existing = dataMap.get(point.timeHours) || { timeHours: point.timeHours };
|
const existing = dataMap.get(point.timeHours) || { timeHours: point.timeHours };
|
||||||
dataMap.set(point.timeHours, {
|
dataMap.set(point.timeHours, {
|
||||||
...existing,
|
...existing,
|
||||||
templateDamph: point.damph,
|
templateDamph: point.damph,
|
||||||
templateLdx: point.ldx
|
templateLdx: point.ldx
|
||||||
});
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return Array.from(dataMap.values()).sort((a, b) => a.timeHours - b.timeHours);
|
return Array.from(dataMap.values()).sort((a, b) => a.timeHours - b.timeHours);
|
||||||
}, [combinedProfile, templateProfile]);
|
}, [combinedProfile, templateProfile, daysWithDeviations]);
|
||||||
|
|
||||||
// Calculate chart dimensions
|
// Calculate chart dimensions
|
||||||
const [containerWidth, setContainerWidth] = React.useState(1000);
|
const [containerWidth, setContainerWidth] = React.useState(1000);
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export const de = {
|
|||||||
xAxisFormat24hDesc: "Wiederholender 0-24h Zyklus",
|
xAxisFormat24hDesc: "Wiederholender 0-24h Zyklus",
|
||||||
xAxisFormat12h: "Tageszeit (12h AM/PM)",
|
xAxisFormat12h: "Tageszeit (12h AM/PM)",
|
||||||
xAxisFormat12hDesc: "Wiederholend 12h Zyklus im AM/PM Format",
|
xAxisFormat12hDesc: "Wiederholend 12h Zyklus im AM/PM Format",
|
||||||
showTemplateDayInChart: "Regulären Plan kontinuierlich im Diagramm anzeigen",
|
showTemplateDayInChart: "Regulären Plan in abweichenden Tagen zusätzlich einblenden",
|
||||||
showDayReferenceLines: "Tagestrenner anzeigen",
|
showDayReferenceLines: "Tagestrenner anzeigen",
|
||||||
simulationDuration: "Simulationsdauer",
|
simulationDuration: "Simulationsdauer",
|
||||||
days: "Tage",
|
days: "Tage",
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ export const en = {
|
|||||||
xAxisFormat24hDesc: "Repeating 0-24h cycle",
|
xAxisFormat24hDesc: "Repeating 0-24h cycle",
|
||||||
xAxisFormat12h: "Time of Day (12h AM/PM)",
|
xAxisFormat12h: "Time of Day (12h AM/PM)",
|
||||||
xAxisFormat12hDesc: "Repeating 12h cycle in AM/PM format",
|
xAxisFormat12hDesc: "Repeating 12h cycle in AM/PM format",
|
||||||
showTemplateDayInChart: "Overlay regular plan in chart",
|
showTemplateDayInChart: "Overlay regular plan for deviating days",
|
||||||
showDayReferenceLines: "Show day separators",
|
showDayReferenceLines: "Show day separators",
|
||||||
simulationDuration: "Simulation Duration",
|
simulationDuration: "Simulation Duration",
|
||||||
days: "Days",
|
days: "Days",
|
||||||
|
|||||||
Reference in New Issue
Block a user