Der Zeitstrahl ist verkehrt……nach rechts müssen die neueren

Zahlen, nicht umgekehrt.
This commit is contained in:
ISA
2024-10-22 10:53:19 +02:00
parent b109d8ddc5
commit 3111a81ba2

View File

@@ -64,21 +64,34 @@ function Kue705FO({
const createChart = (data) => { const createChart = (data) => {
const ctx = document.getElementById("myChart").getContext("2d"); const ctx = document.getElementById("myChart").getContext("2d");
// Funktion zur Umwandlung des Datums in das deutsche Format
const formatToGermanDate = (timestamp) => {
const date = new Date(timestamp);
return new Intl.DateTimeFormat("de-DE", {
day: "2-digit",
month: "2-digit",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
}).format(date);
};
new Chart(ctx, { new Chart(ctx, {
type: "line", type: "line",
data: { data: {
labels: data.map((row) => row.t), // Zeitwerte labels: data.map((row) => formatToGermanDate(row.t)).reverse(), // Zeitwerte ins deutsche Format umwandeln und umkehren
datasets: [ datasets: [
{ {
label: "Isolationswiderstand", label: "Isolationswiderstand",
data: data.map((row) => row.m), data: data.map((row) => row.m).reverse(),
borderColor: "#00AEEF", borderColor: "#00AEEF",
fill: false, fill: false,
yAxisID: "y", yAxisID: "y",
}, },
{ {
label: "Schleifenwiderstand", label: "Schleifenwiderstand",
data: data.map((row) => row.n), data: data.map((row) => row.n).reverse(),
borderColor: "black", borderColor: "black",
fill: false, fill: false,
yAxisID: "y1", yAxisID: "y1",