-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanalysis.html
103 lines (101 loc) · 3.04 KB
/
analysis.html
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
<!DOCTYPE html>
<html>
<head>
<title>ZeroCat</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/echarts/5.3.2/echarts.min.js"></script>
</head>
<body>
<center><div id="main" style="width: 650px; height: 550px"></div></center>
<br><br><center><span id="r" style="color:#999"></span></center>
<script>
setTimeout(() => {
var chartDom = document.getElementById("main");
var myChart = echarts.init(chartDom);
var option;
var h = JSON.parse(decodeURI(location.hash.slice(1, 999)));
var opcodes = {
looks: "外观",
control: "控制",
motion: "移动",
sound: "声音",
event: "事件",
sensing: "侦测",
operator: "运算",
procedures: "自定义",
argument: "参数",
data: "数据",
pen: "画笔",
other: "其它",
};
const data = genData(50);
option = {
title: {
text: h.info,
subtext: "由ZeroCat统计 总积木数:"+data.total,
left: "center",
},
tooltip: {
trigger: "item",
formatter: "{a} <br/>{b} : {c} ({d}%)",
},
legend: {
type: "scroll",
orient: "vertical",
right: 10,
top: 20,
bottom: 20,
data: data.legendData,
},
series: [
{
name: "类别",
type: "pie",
radius: "55%",
center: ["40%", "50%"],
data: data.seriesData,
emphasis: {
itemStyle: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: "rgba(0, 0, 0, 0.5)",
},
},
},
],
};
function genData(count) {
// prettier-ignore
const legendData = [];
const seriesData = [];
let o = Object.keys(h.context),s=0;
for (var i = 0; i < o.length; i++) {
s+=h.context[o[i]];
}
for (var i = 0; i < o.length; i++) {
var name = opcodes[o[i]] || o[i];
legendData.push(name);
seriesData.push({
name: name+' ' + (h.context[o[i]]/s*100).toFixed(1)+"%",
value: h.context[o[i]],
});
}
var infotext = h.infotext
console.log(infotext);
document.getElementById('r').innerHTML=
// "不含圆形积木数:"+h.noreturn+"<br>"+
"变量数:"+infotext.variables+"个<br>"
+"列表数:"+infotext.lists+"个<br>"
+"广播数:"+infotext.broadcasts+"个<br>"
+"总块数:"+infotext.blocks+"块<br>"
+"插件数:"+infotext.extensions+"个<br>";
return {
legendData: legendData,
seriesData: seriesData,
total:s
};
}
option && myChart.setOption(option);
}, 1000);
</script>
</body>
</html>