Fix date formatting in graph tooltips

This commit is contained in:
Girish Ramakrishnan
2025-10-03 18:25:09 +02:00
parent 6977556984
commit b20107ad2a
3 changed files with 10 additions and 10 deletions

View File

@@ -4,7 +4,7 @@
import moment from 'moment-timezone';
import { onMounted, onUnmounted, useTemplateRef, watch } from 'vue';
import Chart from 'chart.js/auto';
import { prettyDecimalSize, prettyLongDate, prettyShortDate } from '@cloudron/pankow/utils';
import { prettyDecimalSize, formatDate } from '@cloudron/pankow/utils';
import annotationPlugin from 'chartjs-plugin-annotation';
Chart.register(annotationPlugin);
@@ -100,7 +100,7 @@ function createGraphOptions({ yscale, period, highMark }) {
tooltip: {
enabled: false,
callbacks: { // passed as title,body to the tooltip renderer
title: (tooltipItem) => period.tooltipFormat === 'long' ? prettyLongDate(tooltipItem[0].raw.x) : prettyShortDate(tooltipItem[0].raw.x),
title: (tooltipItem) => formatDate(period.tooltipFormat, tooltipItem[0].raw.x),
label: (tooltipItem) => {
const datasetLabel = tooltipItem.chart.data.datasets[tooltipItem.datasetIndex].label;
return `${datasetLabel}: <span>${yscale.ticks.callback(tooltipItem.raw.y)}</span>`;