diff --git a/combo/apps/dataviz/models.py b/combo/apps/dataviz/models.py index 085edc0d..65cbe683 100644 --- a/combo/apps/dataviz/models.py +++ b/combo/apps/dataviz/models.py @@ -207,6 +207,9 @@ class ChartNgCell(CellBase): y_labels = loop_labels else: x_labels, y_labels = y_labels, loop_labels + if len(y_labels) != len(data) or not all([len(x) == len(x_labels) for x in data]): + # varying dimensions + raise UnsupportedDataSet() if not x_labels and not y_labels: # unidata x_labels = [''] y_labels = [''] diff --git a/tests/test_dataviz.py b/tests/test_dataviz.py index 363acdc5..21f2c27a 100644 --- a/tests/test_dataviz.py +++ b/tests/test_dataviz.py @@ -94,6 +94,12 @@ VISUALIZATION_JSON = [ 'name': 'eighth visualization (duration)', 'slug': 'eighth', }, + { + 'data-url': 'https://bijoe.example.com/visualization/9/json/', + 'path': 'https://bijoe.example.com/visualization/9/iframe/?signature=123', + 'name': 'nineth visualization (loop over varying dimensions)', + 'slug': 'nineth', + }, ] @@ -190,6 +196,20 @@ def bijoe_mock(url, request): 'unit': 'seconds', } return {'content': json.dumps(response), 'request': request, 'status_code': 200} + if url.path == '/visualization/9/json/': + response = { + 'format': '1', + 'data': [ + [1, 1, 1, 1], + [1], + [1, 1], + ], + 'axis': { + 'y_labels': ['web', 'mail', 'email'], + 'loop': ['a', 'b', 'c', 'd'], + } + } + return {'content': json.dumps(response), 'request': request, 'status_code': 200} def test_chartng_cell(app): @@ -293,6 +313,12 @@ def test_chartng_cell(app): cell.save() chart = cell.get_chart() + # loop/X/Y + cell.data_reference = 'plop:nineth' + cell.save() + with pytest.raises(UnsupportedDataSet): + chart = cell.get_chart() + def test_chartng_cell_view(app, normal_user): page = Page(title='One', slug='index') @@ -390,6 +416,7 @@ def test_chartng_cell_manager(app, admin_user): (u'plop:example', True, u'example visualization (X)'), (u'plop:fifth', False, u'fifth visualization (loop/X)'), (u'plop:fourth', False, u'fourth visualization (no axis)'), + (u'plop:nineth', False, u'nineth visualization (loop over varying dimensions)'), (u'plop:second', False, u'second visualization (Y)'), (u'plop:seventh', False, u'seventh visualization (loop/X/Y)'), (u'plop:sixth', False, u'sixth visualization (loop/Y)'),