Skip to content

Commit

Permalink
Improve report visualization with doughnutpie chart (#164)
Browse files Browse the repository at this point in the history
* Improve report visualization with doughnutpie chart

Co-authored-by: Pavan Kesava Rao <[email protected]>
  • Loading branch information
pavankrao and pavankrao authored Oct 15, 2020
1 parent 9e33819 commit f7d7205
Showing 1 changed file with 48 additions and 4 deletions.
52 changes: 48 additions & 4 deletions report.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,15 +161,59 @@ def run_report(config, blockers, server, header, test_email, no_email, template_
summary['total_unstable'] = "Total UNSTABLE: {}/{} = {}%".format(num_unstable, num_jobs, percent(num_unstable, num_jobs))
summary['total_failure'] = "Total FAILURE: {}/{} = {}%".format(num_failure, num_jobs, percent(num_failure, num_jobs))

# Map color codes with job count and type
jobs_dict = {
'#3465a4': (num_success, 'Success'),
'#515151': (num_aborted, 'Aborted'),
'#ef2929': (num_failure, 'Failure'),
'#704426': (num_error, 'Error'),
'#ffb738': (num_unstable, 'Unstable'),
'#bbbbbb': (num_missing, 'Missing')
}

# Filter only available jobs
bg_color_list, data_list, labels_list = [], [], []
for key, (job_count, job_label) in jobs_dict.items():
if job_count != 0:
bg_color_list.append(key)
data_list.append(job_count)
labels_list.append(job_label)

# create chart config
chart_config = {
'type': 'pie',
'type': 'doughnut',
'data': {
'labels': ['Success', 'Unstable', 'Failed', 'Aborted', 'Missing', 'Error'],
'labels': labels_list,
'datasets': [{
'backgroundColor': ['blue', 'yellow', 'red', 'black', 'grey', 'brown'],
'data': [num_success, num_unstable, num_failure, num_aborted, num_missing, num_error]
'backgroundColor': bg_color_list,
'data': data_list
}]
},
'options': {
'plugins': {
'datalabels': {
'display': 'true',
'align': 'middle',
'backgroundColor': '#fff',
'borderRadius': 20,
'font': {
'weight': 'bold',
}
},
'doughnutlabel': {
'labels': [{
'text': num_jobs,
'font': {
'size': 20,
}
}, {
'text': 'Total Jobs',
'font': {
'size': 15,
}
}]
}
}
}
}
encoded_config = quote(json.dumps(chart_config))
Expand Down

0 comments on commit f7d7205

Please sign in to comment.