visualization: handle no dimension in json_data() (#39362)
This commit is contained in:
parent
0214ccd9e3
commit
76ef3b2fde
|
@ -305,6 +305,12 @@ class Visualization(object):
|
|||
elif len(self.drilldown) == 1:
|
||||
axis, grid = self.table_1d()
|
||||
cells = ((['%s' % x.label], cell_value(grid[x.id])) for x in axis)
|
||||
elif len(self.drilldown) == 0:
|
||||
for row in self.data():
|
||||
cells = [([], cell_value(row.measures[0]))]
|
||||
break
|
||||
else:
|
||||
cells = [([], self.measure.default_value)]
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
|
|
|
@ -207,7 +207,18 @@ def test_truncated_previous_year_range_on_datetime(schema1, app, admin, freezer)
|
|||
]
|
||||
|
||||
|
||||
def test_none_percent_json_data(schema1, app, admin):
|
||||
def test_none_percent_json_data_0d(schema1, app, admin):
|
||||
# test conversion to Javascript declaration
|
||||
visu = Visualization.from_json({
|
||||
'warehouse': 'schema1',
|
||||
'cube': 'facts1',
|
||||
'representation': 'graphical',
|
||||
'measure': 'percent',
|
||||
})
|
||||
assert visu.json_data() == [{u'coords': [], u'measures': [{u'value': 100.0}]}]
|
||||
|
||||
|
||||
def test_none_percent_json_data_2d(schema1, app, admin):
|
||||
# test conversion to Javascript declaration
|
||||
visu = Visualization.from_json({
|
||||
'warehouse': 'schema1',
|
||||
|
|
Loading…
Reference in New Issue