From c0f119c8534d3dc230e78ea63c1b98507923166c Mon Sep 17 00:00:00 2001 From: Andrey Date: Wed, 10 May 2017 08:49:01 +0300 Subject: [PATCH] Fix history timeline legend selection. (#276) --- src/components/state-history-chart-line.html | 7 ++++--- src/components/state-history-chart-timeline.html | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/state-history-chart-line.html b/src/components/state-history-chart-line.html index a54c8a0d18..c3467b4166 100644 --- a/src/components/state-history-chart-line.html +++ b/src/components/state-history-chart-line.html @@ -123,11 +123,12 @@ } daysDelta = (endTime - startTime) / (24 * 3600 * 1000); - if (daysDelta > 30) { + // Avoid rounding up when the API returns a few extra seconds. + if (daysDelta > 30.1) { options.hAxis.format = 'MMM d'; - } else if (daysDelta > 3) { + } else if (daysDelta > 3.1) { options.hAxis.format = 'EEE, MMM d'; - } else if (daysDelta > 1) { + } else if (daysDelta > 1.1) { options.hAxis.format = 'EEE, MMM d, H:mm'; } diff --git a/src/components/state-history-chart-timeline.html b/src/components/state-history-chart-timeline.html index b7767b60a4..9c0bc71379 100644 --- a/src/components/state-history-chart-timeline.html +++ b/src/components/state-history-chart-timeline.html @@ -90,11 +90,12 @@ Polymer({ } format = 'H:mm'; daysDelta = (endTime - startTime) / (24 * 3600 * 1000); - if (daysDelta > 30) { + // Avoid rounding up when the API returns a few extra seconds. + if (daysDelta > 30.1) { format = 'MMM d'; - } else if (daysDelta > 3) { + } else if (daysDelta > 3.1) { format = 'EEE, MMM d'; - } else if (daysDelta > 1) { + } else if (daysDelta > 1.1) { format = 'EEE, MMM d, H:mm'; }