From 0787b0f10c3080bb10b95a913cba1355b557c734 Mon Sep 17 00:00:00 2001 From: Lukas Metzger Date: Thu, 11 Jun 2020 13:42:12 +0200 Subject: Only show location if data is available --- dash/pages/locations.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/dash/pages/locations.py b/dash/pages/locations.py index 85adcfc..c5ed558 100644 --- a/dash/pages/locations.py +++ b/dash/pages/locations.py @@ -88,7 +88,7 @@ def make_content_all(days, date): figure = go.Figure() figure.add_trace(go.Pie( labels=[item['locationname'][0:9] for item in data if item['ip'] == sat], - values=[int(item['totalSessionTime'] / 3600) for item in data if item['ip'] == sat], + values=[item['totalSessionTime'] for item in data if item['ip'] == sat], text=[str(int(item['totalSessionTime'] / 3600)) + ' h' for item in data if item['ip'] == sat], hole=0.3, textinfo='none', @@ -99,7 +99,8 @@ def make_content_all(days, date): title_text = 'Sessiontime per Location
' + sat, showlegend=False ) - figures.append(dbc.Col(width=12, md=6, xl=4, children=dcc.Graph(figure=figure))) + if len([item for item in data if item['ip'] == sat and item['totalSessionTime'] > 0]) > 0: + figures.append(dbc.Col(width=12, md=6, xl=4, children=dcc.Graph(figure=figure))) return figures -- cgit v1.2.3-55-g7522