From 9564c5ed8167d04f63898cf80e5e04cd5ba9a112 Mon Sep 17 00:00:00 2001 From: Tim Date: Sun, 9 Aug 2015 11:46:34 +0200 Subject: [PATCH] Fix bug on graph tooltips where some values were incorrectly converted to dates. Format the header on the history modal to human readable date. --- data/interfaces/default/graphs.html | 19 +++++++------------ .../default/history_table_modal.html | 3 ++- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/data/interfaces/default/graphs.html b/data/interfaces/default/graphs.html index 9ced5250..8699c12f 100644 --- a/data/interfaces/default/graphs.html +++ b/data/interfaces/default/graphs.html @@ -190,7 +190,7 @@ success: function(data) { var dateArray = []; for (var i = 0; i < data.categories.length; i++) { - dateArray.push(moment(data.categories[i]).valueOf()); + dateArray.push(moment(data.categories[i], 'YYYY-MM-DD').valueOf()); } hc_plays_by_day_options.yAxis.min = 0; hc_plays_by_day_options.xAxis.categories = dateArray; @@ -264,7 +264,7 @@ success: function(data) { var dateArray = []; for (var i = 0; i < data.categories.length; i++) { - dateArray.push(moment(data.categories[i]).valueOf()); + dateArray.push(moment(data.categories[i], 'YYYY-MM').valueOf()); } hc_plays_by_month_options.yAxis.min = 0; hc_plays_by_month_options.xAxis.categories = dateArray; @@ -311,8 +311,8 @@ hc_plays_by_month_options.yAxis.labels.formatter = yaxis_format; tooltip_format = function() { - if (moment(this.x).isValid()) { - var s = ''+ moment(this.x).format("ddd MMM D") +''; + if (moment(this.x, 'X').isValid() && (this.x > 946684800)) { + var s = ''+ moment(this.x, 'X').format("ddd MMM D") +''; } else { var s = ''+ this.x +''; } @@ -344,8 +344,8 @@ hc_plays_by_month_options.yAxis.labels.formatter = yaxis_format; tooltip_format = function() { - if (moment(this.x).isValid()) { - var s = ''+ moment(this.x).format("ddd MMM D") +''; + if (moment(this.x, 'X').isValid() && (this.x > 946684800)) { + var s = ''+ moment(this.x, 'X').format("ddd MMM D") +''; } else { var s = ''+ this.x +''; } @@ -356,12 +356,7 @@ return s; } stack_labels_format = function() { - if (moment(this.total).isValid()) { - console.log(this); - var s = moment.duration(this.total, 'seconds').format("H [hrs] m [mins]"); - } else { - var s = this.total; - } + var s = moment.duration(this.total, 'seconds').format("H [hrs] m [mins]"); return s; } hc_plays_by_day_options.tooltip.formatter = tooltip_format; diff --git a/data/interfaces/default/history_table_modal.html b/data/interfaces/default/history_table_modal.html index 5fdb1fcd..f0599592 100644 --- a/data/interfaces/default/history_table_modal.html +++ b/data/interfaces/default/history_table_modal.html @@ -5,7 +5,7 @@ @@ -31,6 +31,7 @@