-
Notifications
You must be signed in to change notification settings - Fork 0
/
quickchart_army.py
52 lines (47 loc) · 1.38 KB
/
quickchart_army.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
from quickchart import QuickChart
def get_quickchart(troop_datas: list, troop_labels: list):
qc = QuickChart()
qc.background_color = 'transparent'
qc.config = {
'type': 'doughnut',
'data': {
'datasets': [
{
'data': troop_datas,
},
],
'labels': troop_labels,
},
'options': {
'plugins': {
'datalabels': {
'color': 'white',
'backgroundColor': '#404040',
'borderRadius': 3,
},
'doughnutlabel': {
'labels': [{
'color': 'white',
'text': sum(troop_datas),
'font': {
'size': 20,
'weight': 'bold'
}
}, {
'text': 'total',
'color': 'white',
}]
}
},
'legend': {
'position': 'bottom',
'labels': {
'fontColor': "white",
}
},
}
}
return qc.get_short_url()
if __name__ == '__main__':
url = get_quickchart([1, 2, 3, 4], ['test1', 'test2', 'test3', 'test4'])
print(url)