Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
fixup: tootltip date format
Browse files Browse the repository at this point in the history
  • Loading branch information
koying committed Jul 12, 2021
1 parent 0f78d00 commit abc067a
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions weather-card-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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',
});
});;
}
}
}
Expand Down

0 comments on commit abc067a

Please sign in to comment.