forked from Seowyh/nusmoney
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuserExpensePie.js
115 lines (112 loc) · 2.06 KB
/
userExpensePie.js
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
const urlCat = 'http://localhost:3000/transaction/byCat';
var pieData;
var pie = null;
async function getTranByCat() {
let val1 = document.getElementById("user").value;
let val2 = document.getElementById("pw").value;
let payload ={
params: {
"username" : val1,
"password" : val2
}
};
await axios.get(urlCat, payload)
.then((response) => {
console.log(response.data);
pieData = response.data;
if (typeof(pie) == Object) {
console.log("pie destroyed")
pie.destroy();
}
showPieChart();})
.catch(function (error) {
console.log(error);
});
}
function showPieChart(){
if (pie !== null) {
console.log("pie destroyed")
pie.destroy();
}
console.log(typeof(pie));
pie = new d3pie("chartDivUser", {
"header": {
"title": {
"text": "Expense Journal",
"fontSize": 24,
"font": "open sans"
},
"subtitle": {
"text": "by categories across accounts",
"color": "#999999",
"fontSize": 12,
"font": "open sans"
},
"location": "pie-center",
"titleSubtitlePadding": 9
},
"footer": {
"color": "#999999",
"fontSize": 10,
"font": "open sans",
"location": "bottom-left"
},
"size": {
"canvasHeight": 400,
"canvasWidth": 600,
"pieInnerRadius": "68%",
"pieOuterRadius": "90%"
},
"data": {
"sortOrder": "value-desc",
"smallSegmentGrouping": {
"enabled": true,
"value": 5
},
"content": pieData
},
"labels": {
"outer": {
"pieDistance": 32
},
"inner": {
"hideWhenLessThanPercentage": 4
},
"mainLabel": {
"fontSize": 11
},
"percentage": {
"color": "#ffffff",
"decimalPlaces": 0
},
"value": {
"color": "#adadad",
"fontSize": 11
},
"lines": {
"enabled": true
},
"truncation": {
"enabled": true
}
},
"tooltips": {
"enabled": true,
"type": "placeholder",
"string": "{label}: '$'{value}"
},
"effects": {
"pullOutSegmentOnClick": {
"effect": "linear",
"speed": 400,
"size": 8
}
},
"misc": {
"gradient": {
"enabled": true,
"percentage": 100
}
}
});
}