-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathstart-chart.html
101 lines (93 loc) · 2.41 KB
/
start-chart.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Benchmark Chart</title>
<script src="https://cdn.jsdelivr.net/npm/echarts"></script>
</head>
<body>
<div id="myChart" style="width: 100%; height: 810px"></div>
<script>
const finallyData = {
"Webpack(babel) 5.89.0": {
"startup(serverStartTime + onLoadTime)": ,
rootHmr: ,
leafHmr: ,
buildTime: ,
},
"Vite 5.0.4": {
"startup(serverStartTime + onLoadTime)": ,
rootHmr: ,
leafHmr: ,
buildTime: ,
},
"Rspack 0.4.1": {
"startup(serverStartTime + onLoadTime)": ,
rootHmr: ,
leafHmr: ,
buildTime: ,
},
"Farm 0.14.14": {
"startup(serverStartTime + onLoadTime)": ,
rootHmr: ,
leafHmr: ,
buildTime: ,
},
};
const keys = Object.keys(finallyData);
const values = keys.map((key) => finallyData[key]);
const chartContainer = document.getElementById("myChart");
const myChart = echarts.init(chartContainer);
const seriesData = Object.keys(values[0]).map((label, index) => ({
name: label,
type: "bar",
data: keys.map((key) => finallyData[key][label]),
itemStyle: {
color: randomColor(),
},
label: {
show: true,
position: "right",
textStyle: {
fontSize: 16,
},
},
}));
function randomColor() {
return (
"rgba(" +
Math.round(Math.random() * 255) +
"," +
Math.round(Math.random() * 255) +
"," +
Math.round(Math.random() * 255) +
",0.8)"
);
}
function renderChart() {
const option = {
xAxis: {
type: "value",
},
yAxis: {
type: "category",
data: keys,
axisLabel: {
interval: 0,
},
},
legend: {
data: Object.keys(values[0]),
},
series: seriesData,
};
myChart.setOption(option);
}
renderChart();
window.addEventListener("resize", function () {
myChart.resize();
});
</script>
</body>
</html>