From be88b32a8e33797dc884fe07c6d8c229ee6e4607 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 13 Jan 2020 11:26:50 +0100 Subject: [PATCH] visualisation: return 0.0 for None measures in json_data (#38913) --- bijoe/schemas.py | 8 ++++++++ bijoe/visualization/utils.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bijoe/schemas.py b/bijoe/schemas.py index 7adf428..9362408 100644 --- a/bijoe/schemas.py +++ b/bijoe/schemas.py @@ -137,6 +137,14 @@ class Measure(Base): 'expression': str, } + @property + def default_value(self): + if self.type in ['integer', 'percent']: + return 0 + if self.type == 'duration': + return datetime.timedelta(seconds=0) + return None + class Dimension(Base): __slots__ = ['name', 'label', 'type', 'join', 'value', 'value_label', diff --git a/bijoe/visualization/utils.py b/bijoe/visualization/utils.py index 034b141..822548d 100644 --- a/bijoe/visualization/utils.py +++ b/bijoe/visualization/utils.py @@ -177,7 +177,7 @@ class Visualization(object): return data def default_cell(self): - return MeasureCell(measure=self.measure, value=None) + return MeasureCell(measure=self.measure, value=self.measure.default_value) def table_2d(self): '''Layout data into 2d tables''' -- 2.24.0