dataviz: transpose data before ods export to match html display (#85654)
This commit is contained in:
parent
b20464820a
commit
5e8b58c6ca
|
@ -150,6 +150,8 @@ class DatavizGraphView(DetailView):
|
|||
line = [x or 0 for x in line]
|
||||
data.append(line)
|
||||
|
||||
data = [list(line) for line in zip(*data)]
|
||||
|
||||
output = io.BytesIO()
|
||||
pyexcel_ods.save_data(output, {self.cell.title or self.cell.statistic.label: data})
|
||||
output.seek(0)
|
||||
|
|
|
@ -1669,9 +1669,10 @@ def test_chartng_cell_view_new_api_export(app, normal_user, new_api_statistics):
|
|||
|
||||
data = pyexcel_ods.get_data(io.BytesIO(ods_resp.body))
|
||||
assert data['Two series stat'] == [
|
||||
['', '2020-10', '2020-11', '2020-12'],
|
||||
['Serie 1', 0, 16, 2],
|
||||
['Serie 2', 2, 1, 0],
|
||||
['', 'Serie 1', 'Serie 2'],
|
||||
['2020-10', 0, 2],
|
||||
['2020-11', 16, 1],
|
||||
['2020-12', 2, 0],
|
||||
]
|
||||
|
||||
cell.statistic = Statistic.objects.get(slug='empty-x-labels')
|
||||
|
@ -1679,7 +1680,7 @@ def test_chartng_cell_view_new_api_export(app, normal_user, new_api_statistics):
|
|||
|
||||
ods_resp = resp.form.submit().follow()
|
||||
data = pyexcel_ods.get_data(io.BytesIO(ods_resp.body))
|
||||
assert data['Empty x_labels'] == [['Serie 1', 4242]]
|
||||
assert data['Empty x_labels'] == [['Serie 1'], [4242]]
|
||||
|
||||
|
||||
@with_httmock(bijoe_mock)
|
||||
|
|
Loading…
Reference in New Issue