dataviz: do not show total for single point data (#73685)
gitea/combo/pipeline/pr-main This commit looks good
Details
gitea/combo/pipeline/pr-main This commit looks good
Details
This commit is contained in:
parent
afab6c189a
commit
1a0b9c8266
|
@ -609,6 +609,11 @@ class ChartNgCell(CellBase):
|
|||
def add_total_to_line_table(chart, data):
|
||||
# workaround pygal
|
||||
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))
|
||||
chart.x_labels.append(gettext('Total'))
|
||||
return data
|
||||
|
|
|
@ -1954,6 +1954,12 @@ def test_table_cell_new_api(app, admin_user, new_api_statistics):
|
|||
resp = app.get(location)
|
||||
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):
|
||||
all_stats_count = Statistic.objects.count()
|
||||
|
|
Loading…
Reference in New Issue