feat: implement Date in anlog inputs chart

This commit is contained in:
ISA
2025-06-27 13:58:34 +02:00
parent 0b70ef68e9
commit 4b19884c1e
6 changed files with 36 additions and 10 deletions

View File

@@ -113,7 +113,23 @@ export default function AnalogInputsChart({
responsive: true,
plugins: {
legend: { position: "top" as const },
tooltip: { mode: "index" as const, intersect: false },
tooltip: {
mode: "index" as const,
intersect: false,
callbacks: {
label: function (context: import("chart.js").TooltipItem<"line">) {
const y = context.parsed.y;
return `Messwert: ${y}`;
},
title: function (
tooltipItems: import("chart.js").TooltipItem<"line">[]
) {
const date = tooltipItems[0].parsed.x;
return `Zeitpunkt: ${new Date(date).toLocaleString("de-DE")}`;
},
},
},
title: {
display: true,
text: `Verlauf der letzten 24 Stunden`,
@@ -134,13 +150,13 @@ export default function AnalogInputsChart({
x: {
type: "time" as const,
time: {
unit: "hour" as const,
tooltipFormat: "HH:mm 'Uhr' dd.MM.",
unit: "day", // nur Datum in Achse
tooltipFormat: "dd.MM.yyyy HH:mm", // aber Uhrzeit im Tooltip sichtbar
displayFormats: {
hour: "HH:mm",
day: "dd.MM.",
day: "dd.MM.yyyy",
},
},
adapters: {
date: {
locale: de,