Messkurve für Schleife wird angezeigt

This commit is contained in:
Ismail Ali
2025-01-25 07:55:23 +01:00
parent 4f809877ea
commit 81aef743f1

View File

@@ -281,84 +281,95 @@ const Kue705FO: React.FC<Kue705FOProps> = ({
const createLoopChart = (data: DataLoop[], title: string) => { const createLoopChart = (data: DataLoop[], title: string) => {
const canvas = document.getElementById("myChart") as HTMLCanvasElement; const canvas = document.getElementById("myChart") as HTMLCanvasElement;
const ctx = canvas?.getContext("2d"); if (!canvas) {
if (!ctx) { console.error("Canvas mit ID 'myChart' nicht gefunden.");
console.error("Canvas context konnte nicht gefunden werden");
return; return;
} }
const createLoopChart = (data: DataLoop[], title: string) => { const ctx = canvas.getContext("2d");
const canvas = document.getElementById("myChart") as HTMLCanvasElement; if (!ctx) {
const ctx = canvas?.getContext("2d"); console.error("2D-Kontext für Canvas konnte nicht erstellt werden.");
if (!ctx) { return;
console.error("Canvas context konnte nicht gefunden werden"); }
return;
}
new Chart(ctx, { // Konvertiere Zeitstempel in ein lesbares Format für die X-Achse
type: "line", const labels = data.map((row) => {
data: { const date = new Date(row.t.replace(/-/g, "/")); // Zeitstring parsen
labels: data.map((row) => new Date(row.t).toLocaleString("de-DE")), return date.toLocaleString("de-DE", {
datasets: [ hour: "2-digit",
{ minute: "2-digit",
label: "Isolationswiderstand (MOhm)", second: "2-digit",
data: data.map((row) => row.m),
borderColor: "#00AEEF",
borderWidth: 1,
tension: 0.1, // Ersatz für lineTension
pointRadius: 0.3,
pointHoverRadius: 5,
fill: false,
yAxisID: "y",
},
{
label: "Schleifenwiderstand (kOhm)",
data: data.map((row) => row.n),
borderColor: "black",
borderWidth: 1,
tension: 0.1, // Ersatz für lineTension
pointRadius: 0.3,
pointHoverRadius: 5,
fill: false,
yAxisID: "y1",
},
],
},
options: {
scales: {
y: {
type: "linear",
position: "left",
title: { display: true, text: "MOhm" },
},
y1: {
type: "linear",
position: "right",
title: { display: true, text: "kOhm" },
},
},
plugins: {
zoom: {
pan: {
enabled: true,
mode: "xy",
},
zoom: {
wheel: {
enabled: true,
},
pinch: {
enabled: true,
},
mode: "xy",
},
},
},
},
}); });
}; });
new Chart(ctx, {
type: "line",
data: {
labels,
datasets: [
{
label: "Isolationswiderstand (MOhm)",
data: data.map((row) => row.m),
borderColor: "#00AEEF",
borderWidth: 1,
tension: 0.1, // Glättung der Linie
pointRadius: 1,
pointHoverRadius: 5,
fill: false,
yAxisID: "y",
},
{
label: "Schleifenwiderstand (kOhm)",
data: data.map((row) => row.n),
borderColor: "black",
borderWidth: 1,
tension: 0.1,
pointRadius: 1,
pointHoverRadius: 5,
fill: false,
yAxisID: "y1",
},
],
},
options: {
scales: {
x: {
type: "category",
title: { display: true, text: "Zeit" },
},
y: {
type: "linear",
position: "left",
title: { display: true, text: "MOhm" },
},
y1: {
type: "linear",
position: "right",
title: { display: true, text: "kOhm" },
},
},
plugins: {
zoom: {
pan: {
enabled: true,
mode: "xy",
},
zoom: {
wheel: {
enabled: true,
},
pinch: {
enabled: true,
},
mode: "xy",
},
},
},
},
});
}; };
useEffect(() => { useEffect(() => {
const updateAlarmStatus = () => { const updateAlarmStatus = () => {
const alarmStatus = const alarmStatus =