dataviz: do not show total for single point data (#73685) #50
|
@ -609,6 +609,11 @@ class ChartNgCell(CellBase):
|
||||||
def add_total_to_line_table(chart, data):
|
def add_total_to_line_table(chart, data):
|
||||||
# workaround pygal
|
# workaround pygal
|
||||||
chart.compute_sum = False
|
chart.compute_sum = False
|
||||||
|
|
||||||
|
# do not add total for single point
|
||||||
|
if len(data) <= 1:
|
||||||
|
return data
|
||||||
|
|
||||||
data.append(sum(x for x in data if x is not None))
|
data.append(sum(x for x in data if x is not None))
|
||||||
chart.x_labels.append(gettext('Total'))
|
chart.x_labels.append(gettext('Total'))
|
||||||
return data
|
return data
|
||||||
|
|
|
@ -1954,6 +1954,12 @@ def test_table_cell_new_api(app, admin_user, new_api_statistics):
|
||||||
resp = app.get(location)
|
resp = app.get(location)
|
||||||
assert resp.text.count('Total') == 0
|
assert resp.text.count('Total') == 0
|
||||||
|
|
||||||
|
# no total for single point data
|
||||||
|
cell.statistic = Statistic.objects.get(slug='empty-x-labels')
|
||||||
|
cell.save()
|
||||||
|
resp = app.get(location)
|
||||||
|
assert resp.text.count('Total') == 0
|
||||||
|
|
||||||
|
|
||||||
def test_dataviz_hourly_unavailable_statistic(statistics, nocache):
|
def test_dataviz_hourly_unavailable_statistic(statistics, nocache):
|
||||||
all_stats_count = Statistic.objects.count()
|
all_stats_count = Statistic.objects.count()
|
||||||
|
|
Loading…
Reference in New Issue