feat(analogInputsChart): zeige Minimum (i) und Maximum (a) als zusätzliche Linien im Chart
- Chart zeigt jetzt Messwert (m), Minimum (i, grün) und Maximum (a, rot) für ausgewählten Zeitraum - Tooltip und Legende angepasst - Typdefinitionen für Chart
This commit is contained in:
@@ -59,7 +59,7 @@ export default function AnalogInputsChart() {
|
||||
}, []);
|
||||
|
||||
const dispatch = useDispatch<AppDispatch>();
|
||||
const chartRef = useRef<ChartJS | null>(null);
|
||||
const chartRef = useRef<any>(null);
|
||||
|
||||
const { zeitraum, vonDatum, bisDatum, data, autoLoad, selectedId } =
|
||||
useSelector((state: RootState) => state.analogInputsHistory);
|
||||
@@ -83,10 +83,13 @@ export default function AnalogInputsChart() {
|
||||
})
|
||||
);
|
||||
|
||||
if (chartRef.current) {
|
||||
if (
|
||||
chartRef.current &&
|
||||
chartRef.current.options &&
|
||||
chartRef.current.options.scales &&
|
||||
chartRef.current.options.scales.x
|
||||
) {
|
||||
const chart = chartRef.current;
|
||||
|
||||
// Aktualisiere die X-Achse basierend auf den neuesten Werten
|
||||
chart.options.scales.x.min = new Date(latestVonDatum).getTime();
|
||||
chart.options.scales.x.max = new Date(latestBisDatum).getTime();
|
||||
|
||||
@@ -107,7 +110,10 @@ export default function AnalogInputsChart() {
|
||||
label: selectedAnalogInput?.label
|
||||
? `Messwerteingang ${selectedAnalogInput.label}`
|
||||
: "Messwerte",
|
||||
data: filteredData.map((point) => ({ x: point.t, y: point.m })),
|
||||
data: filteredData.map((point) => ({
|
||||
x: new Date(point.t),
|
||||
y: point.m,
|
||||
})),
|
||||
fill: false,
|
||||
borderColor: getColor("littwin-blue"),
|
||||
backgroundColor: "rgba(59,130,246,0.3)",
|
||||
@@ -117,7 +123,6 @@ export default function AnalogInputsChart() {
|
||||
},
|
||||
];
|
||||
|
||||
// Erzwinge ein vollständiges Redraw des Diagramms
|
||||
chart.update("none");
|
||||
}
|
||||
};
|
||||
@@ -177,7 +182,10 @@ export default function AnalogInputsChart() {
|
||||
label: selectedAnalogInput?.label
|
||||
? `Messwert (m) ${selectedAnalogInput.label}`
|
||||
: "Messwert (m)",
|
||||
data: filteredData.map((point) => ({ x: point.t, y: point.m })),
|
||||
data: filteredData.map((point) => ({
|
||||
x: new Date(point.t),
|
||||
y: point.m,
|
||||
})),
|
||||
fill: false,
|
||||
borderColor: getColor("littwin-blue"),
|
||||
backgroundColor: "rgba(59,130,246,0.3)",
|
||||
@@ -189,7 +197,7 @@ export default function AnalogInputsChart() {
|
||||
label: "Minimum (i)",
|
||||
data: filteredData
|
||||
.filter((point) => typeof point.i === "number")
|
||||
.map((point) => ({ x: point.t, y: point.i })),
|
||||
.map((point) => ({ x: new Date(point.t), y: point.i })),
|
||||
fill: false,
|
||||
borderColor: "#22c55e", // grün
|
||||
borderWidth: 1,
|
||||
@@ -201,7 +209,7 @@ export default function AnalogInputsChart() {
|
||||
label: "Maximum (a)",
|
||||
data: filteredData
|
||||
.filter((point) => typeof point.a === "number")
|
||||
.map((point) => ({ x: point.t, y: point.a })),
|
||||
.map((point) => ({ x: new Date(point.t), y: point.a })),
|
||||
fill: false,
|
||||
borderColor: "#ef4444", // rot
|
||||
borderWidth: 1,
|
||||
|
||||
Reference in New Issue
Block a user