This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgraphics.py
156 lines (137 loc) · 5.35 KB
/
graphics.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
def graphic_3D_pie (heading, sub_title, axis_x_description, axis_y_description, theme, source_data) :
data_source = {}
data_source['chart'] = {
"caption": heading,
"subCaption": sub_title,
"xAxisName": axis_x_description,
"yAxisName": axis_y_description,
"theme": theme,
"numberPrefix": "",
"showlegend": "1",
"placevaluesInside": "1",
"showpercentvalues": "1",
"rotatevalues": "1",
#Showing canvas bg to apply background color
"showCanvasBg": "1",
#Shwoing canvas base to apply base color
"showCanvasBase": "1",
#Changing canvas base depth
"canvasBaseDepth": "14",
#Changing canvas background depth
"canvasBgDepth": "5",
#Changing canvas base color
"canvasBaseColor": "#aaaaaa",
#Changing canvas background color
"canvasBgColor": "#eeeeee",
"exportEnabled": "1"
}
data =[]
for key , values in source_data.items() :
data_dict = {}
data_dict['label'] = key
data_dict['value'] = values
data.append(data_dict)
data_source['data'] = data
return data_source
def column_graphic_dict (heading, sub_caption, x_axis_name, y_axis_name, theme, source_data) :
data_source = {}
data_source['chart'] = {
"caption": heading,
"subCaption": sub_caption,
"xAxisName": x_axis_name,
"yAxisName": y_axis_name,
"theme": theme,
"numberPrefix": "",
"placevaluesInside": "1",
"rotatevalues": "1",
#Showing canvas bg to apply background color
"showCanvasBg": "1",
#Shwoing canvas base to apply base color
"showCanvasBase": "1",
#Changing canvas base depth
"canvasBaseDepth": "14",
#Changing canvas background depth
"canvasBgDepth": "5",
#Changing canvas base color
"canvasBaseColor": "#aaaaaa",
#Changing canvas background color
"canvasBgColor": "#eeeeee",
"exportEnabled": "1"
}
data =[]
for key , values in source_data.items() :
data_dict = {}
data_dict['label'] = key
data_dict['value'] = values
data.append(data_dict)
data_source['data'] = data
return data_source
def column_graphic_tupla (heading, sub_caption, x_axis_name, y_axis_name, theme, source_data) :
data_source = {}
data_source['chart'] = {
"caption": heading,
"subCaption": sub_caption,
"xAxisName": x_axis_name,
"yAxisName": y_axis_name,
"theme": theme,
"numberPrefix": "",
"placevaluesInside": "1",
"rotatevalues": "1",
#Showing canvas bg to apply background color
"showCanvasBg": "1",
#Shwoing canvas base to apply base color
"showCanvasBase": "1",
#Changing canvas base depth
"canvasBaseDepth": "14",
#Changing canvas background depth
"canvasBgDepth": "5",
#Changing canvas base color
"canvasBaseColor": "#aaaaaa",
#Changing canvas background color
"canvasBgColor": "#eeeeee",
"exportEnabled": "1"
}
data =[]
for key , values in source_data :
data_dict = {}
data_dict['label'] = key
data_dict['value'] = int(values)
data.append(data_dict)
data_source['data'] = data
return data_source
def column_graphic_per_time (heading, sub_caption, x_axis_name, y_axis_name, time_values , service_values):
data_source = {}
# Chart data is passed to the `dataSource` parameter, as hashes, in the form of
# key-value pairs.
data_source['chart'] = {
"caption": heading,
"subCaption": sub_caption,
"xAxisName": x_axis_name,
"yAxisName": y_axis_name,
#"theme": theme,
"palette": "2",
"numberprefix": "",
"showvalues": "0",
"legendshadow": "0",
"legendborderalpha": "0",
#"yaxismaxvalue": "90",
"legendbgcolor": "FFFFFF",
"exportEnabled": "1"
}
category_list = []
for key in time_values :
category_list.append({ "label": key, "stepSkipped": 'false',"appliedSmartLabel": 'true'})
data_source["categories"] = [{"category": category_list}]
index_color = ["005476", "a1c74a", "9966ff", "ffcc66","cc8800","ccff66", "0086b3" , "5c5c8a", "cc6699", "006699"]
data_set_list =[]
counter = 0
for key ,values in service_values.items():
series_name_list =[]
for date in time_values :
series_name_list.append({"value" : service_values[key][date]})
data_set_list.append({"seriesname": key, "color": index_color[counter],'data' : series_name_list})
counter +=1
if counter > len(index_color):
counter = 0
data_source ["dataset"] =data_set_list
return data_source