summaryrefslogtreecommitdiffstats
path: root/dash
diff options
context:
space:
mode:
authorLukas Metzger2020-07-02 12:42:39 +0200
committerLukas Metzger2020-07-02 12:42:39 +0200
commit8edfc87a3fb2ee41fa31fd7fb2f653e050dd3083 (patch)
tree2f83b2cb825d6fae57748799abf7edb2366dc952 /dash
parentAdded prettytime function and use it (diff)
downloadbwlp-statistics-8edfc87a3fb2ee41fa31fd7fb2f653e050dd3083.tar.gz
bwlp-statistics-8edfc87a3fb2ee41fa31fd7fb2f653e050dd3083.tar.xz
bwlp-statistics-8edfc87a3fb2ee41fa31fd7fb2f653e050dd3083.zip
Added additional prettytime
Diffstat (limited to 'dash')
-rw-r--r--dash/pages/locations.py8
-rw-r--r--dash/pages/total.py3
-rw-r--r--dash/prettytime.py3
3 files changed, 12 insertions, 2 deletions
diff --git a/dash/pages/locations.py b/dash/pages/locations.py
index 13aa752..74e86b2 100644
--- a/dash/pages/locations.py
+++ b/dash/pages/locations.py
@@ -133,7 +133,9 @@ def make_content_sat_sessiontime(days, date, satellite):
figure = go.Figure()
figure.add_trace(go.Bar(
x=[item['locationname'][0:9] for item in data],
- y=[int(item['totalSessionTime'] / 3600) for item in data]
+ y=[int(item['totalSessionTime'] / 3600) for item in data],
+ hovertext=[prettytime(item['totalSessionTime']) for item in data],
+ hoverinfo='text'
))
figure.update_layout(
title_text = 'Total Session Time',
@@ -163,7 +165,9 @@ def make_content_sat_median(days, date, satellite):
figure = go.Figure()
figure.add_trace(go.Bar(
x=[item['locationname'][0:9] for item in data],
- y=[int(item['medianSessionLength'] / 60) for item in data]
+ y=[int(item['medianSessionLength'] / 60) for item in data],
+ hovertext=[prettytime(item['medianSessionLength']) for item in data],
+ hoverinfo='text'
))
figure.update_layout(
title_text = 'Median Session Time',
diff --git a/dash/pages/total.py b/dash/pages/total.py
index e21c4b7..461c03a 100644
--- a/dash/pages/total.py
+++ b/dash/pages/total.py
@@ -100,18 +100,21 @@ def make_graph_times(days, rangeStart, rangeEnd, satellites):
figure.add_trace(go.Scatter(
x=[item['date'] for item in data],
y=[int(item['totalTime'] / 3600) for item in data],
+ hovertext=['({})'.format(prettytime(item['totalTime'])) for item in data],
mode='lines+markers',
name='Total Time'
))
figure.add_trace(go.Scatter(
x=[item['date'] for item in data],
y=[int(item['totalSessionTime'] / 3600) for item in data],
+ hovertext=['({})'.format(prettytime(item['totalSessionTime'])) for item in data],
mode='lines+markers',
name='Total Session Time'
))
figure.add_trace(go.Scatter(
x=[item['date'] for item in data],
y=[int(item['totalOffTime'] / 3600) for item in data],
+ hovertext=['({})'.format(prettytime(item['totalOffTime'])) for item in data],
mode='lines+markers',
name='Total Off Time'
))
diff --git a/dash/prettytime.py b/dash/prettytime.py
index 6e9e562..3cb47b4 100644
--- a/dash/prettytime.py
+++ b/dash/prettytime.py
@@ -13,5 +13,8 @@ def prettytime(seconds, prec = 2):
else:
output.append('{} {}'.format(time, unit))
+ if len(output) == 0:
+ output.append('0 seconds')
+
return ', '.join(output[:prec])