Fix date formatting in graph tooltips
This commit is contained in:
@@ -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>`;
|
||||
|
||||
Reference in New Issue
Block a user