-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathchart.py
99 lines (78 loc) · 2.48 KB
/
chart.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import plotly
import plotly.graph_objs as go
import numpy as np
import plotly.plotly as py
def create_chart(overall_result,tag_results =''):
"""
:param overall_result: This is the overall results stats
:param tag_results: These are tags in the output.xml
:return: html widget
"""
html_data = ''
## Overall percentage graph
overall_list = []
## Total Execution Report
if overall_result != '':
overall_list.append(int(overall_result['pass']))
overall_list.append(int(overall_result['fail']))
fig = {
"data": [
{
"values": overall_list,
"labels": [ "Pass", "Fail" ],
'marker': {'colors': ['rgb(12, 227, 107)',
'rgb(255, 94, 51)']},
"domain": {"x": [0, .48]},
"name": "Total Test Case ",
"hoverinfo":"label",
"hole": .4,
"type": "pie"
}
],
"layout": {
"title":"Total Execution Percentage",
"annotations": [
{
"font": {
"size": 10
},
"showarrow": False,
"text": "Total Percenatage",
"x": 0.20,
"y": 0.5
}
] ,
}
}
# plotly.offline.plot(fig, filename='donut.html',validate=False)
total_percentage = plotly.offline.plot(fig, output_type = 'div' )
html_data += total_percentage
## Print the statistics based in tags
passed_values = []
failed_values = []
tag_list = []
for key,value in tag_results.items():
tag_list.append(key)
for tags in tag_list:
passed_values.append(tag_results[tags]['pass'])
failed_values.append(tag_results[tags]['fail'])
trace1 = go.Bar(
x=tag_list,
y=passed_values,
name='Passed'
)
trace2 = go.Bar(
x=tag_list,
y=failed_values,
name='Failed'
)
data = [trace1, trace2]
layout = go.Layout(
title="Tag wise percentage",
barmode='group'
)
group_bar = go.Figure(data=data, layout=layout)
# plotly.offline.plot(fig, filename='grouped-bar.html',validate=False)
cust_wise_percent = plotly.offline.plot(group_bar, output_type='div')
html_data += cust_wise_percent
return html_data