feat: implement Date in anlog inputs chart
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user