From abc067a1935e2d982e958e774114fcde659aba63 Mon Sep 17 00:00:00 2001 From: Chris Browet Date: Sun, 11 Jul 2021 11:17:52 +0200 Subject: [PATCH] fixup: tootltip date format --- weather-card-chart.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/weather-card-chart.js b/weather-card-chart.js index cb66f38..9dfd809 100644 --- a/weather-card-chart.js +++ b/weather-card-chart.js @@ -346,10 +346,6 @@ class WeatherCardChart extends Polymer.Element { fill: false, tooltip: { callbacks: { - title: function(context) { - var label = context.dataset.label || ''; - return label += ': ' + context.parsed.y + tempUnit; - }, label: function(context) { var label = context.dataset.label || ''; return label += ': ' + context.parsed.y + tempUnit; @@ -372,10 +368,6 @@ class WeatherCardChart extends Polymer.Element { fill: false, tooltip: { callbacks: { - title: function(context) { - var label = context.dataset.label || ''; - return label += ': ' + context.parsed.y + tempUnit; - }, label: function(context) { var label = context.dataset.label || ''; return label += ': ' + context.parsed.y + tempUnit; @@ -523,13 +515,18 @@ class WeatherCardChart extends Polymer.Element { tooltip: { callbacks: { title: function(context) { - return new Date(context[0].label).toLocaleDateString(locale, { + var date = new Date(context[0].label); + if (mode == 'hourly') { + return date.toLocaleTimeString(locale, { + hour: 'numeric', + minute: 'numeric', + }); + } + return date.toLocaleDateString(locale, { month: 'long', day: 'numeric', weekday: 'long', - hour: 'numeric', - minute: 'numeric', - }); + });; } } }