This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathrenderlogic_template.js
216 lines (215 loc) · 4.69 KB
/
renderlogic_template.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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
const raw_data = JSON.parse('{{raw_data}}')
const render_date = '{{render_date}}'
const container = document.getElementById('main')
container.style.width="1080px"
container.style.height= raw_data.length * 48 + "px"
const container2 = document.getElementById('main2')
container2.style.width="1080px"
container2.style.height= raw_data.length * 48 + "px"
const myChart = echarts.init(container);
const myChart2 = echarts.init(container2);
const colors = ['#454C6F', '#D1DDE2', '#7A97A3', '#A89882', '#484E2A', '#EDF0F4', '#C2B7A7']
let option = {
title: [
{
text: 'The Computer Language Benchmarks Game Visualization',
link: "https://benchmarksgame-team.pages.debian.net/benchmarksgame/index.html",
textStyle: {
fontStyle: "normal",
fontFamily: "Arial",
fontSize: 23,
},
top: "4px",
left: '50%',
textAlign: "center",
subtextStyle: {
color: colors[0]
}
},
{
text: "Data source from benchmarksgame-team.pages.debian.net\nRender by GoodManWEN/Programming-Language-Benchmarks-Visualization.git",
link: "https://github.com/GoodManWEN/Programming-Language-Benchmarks-Visualization",
textStyle: {
fontStyle: "normal",
fontFamily: "Arial",
fontWeight: "normal",
color: colors[0],
opacity: 0.5,
fontSize: 13,
lineHeight: 16,
},
top: 'bottom',
left: 'right',
},
{
text: "Update date: "+render_date,
textStyle: {
fontStyle: "normal",
fontFamily: "Arial",
fontWeight: "normal",
color: colors[0],
opacity: 0.5,
fontSize: 14,
},
top: "28px",
left: 'right',
},
],
tooltip: {
trigger: 'axis',
},
legend: {
data: ['Time consumption(multiplier)','Ranking (weighted by time and memory)'],
top: '30px',
left: '23%',
textStyle: {
fontSize: 15,
},
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value',
name: 'Time consumption\n(multiplier)',
nameLocation: "start",
min: 0,
max: value => Math.round(Math.min(value.max * 1.08, value.max + 10)),
splitLine: {
show: false,
},
axisLabel: {
formatter: '{value}x',
fontSize: 15,
},
},
yAxis: {
type: 'category',
name: 'Language',
nameLocation: "start",
data: raw_data.map(item => item[0]),
axisLine: {
lineStyle: {
color: colors[0]
}
},
axisLabel: {
fontSize: 15,
},
inverse: true,
},
series: [
{
name: 'Time consumption(multiplier)',
type: 'bar',
itemStyle: {
color: colors[2],
opacity:0.8,
},
data: raw_data.map(item => item[1]),
label: {
show: true,
position: 'right',
color: colors[0],
fontSize: 14,
formatter: '{c}x',
},
},
{
name: 'Ranking (weighted by time and memory)',
type: 'pie',
itemStyle: {
color: colors[6],
opacity:0.88,
},
label: {
show: true,
position: 'right',
color: colors[4],
formatter: '{c}x',
},
},
],
};
let option2 = {
tooltip: {
trigger: 'axis',
},
legend: {
data: []
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true
},
xAxis: {
type: 'value',
inverse: true,
splitArea: {
show: true,
},
axisLabel: {
opacity: 0,
fontSize: 15,
},
splitLine: {
lineStyle: {
color: colors[1],
opacity: 0.5
}
},
},
yAxis: {
type: 'category',
data: raw_data.map(item => item[0]),
inverse: true,
axisLabel: {
opacity: 0,
fontSize: 15,
}
},
series: [
{
name: 'Time',
type: 'bar',
itemStyle: {
color: colors[3],
opacity:0.8,
},
data: raw_data.map(item => raw_data.length + 1 - item[2]),
label: {
show: true,
position: 'right',
color: colors[4],
fontSize: 14,
formatter: (params) => {
let num = raw_data.length - params.data + 1;
let str = ""
if (num < 10) {
str = ' ' + num
}
else {
str = num.toString()
}
if (str.substr(str.length-1,1) === '1' ) {
str += "st"
} else if (str.substr(str.length-1,1) === '2' ) {
str += "nd"
} else if (str.substr(str.length-1,1) === '3' ) {
str += "rd"
} else {
str += "th"
}
return str
},
},
},
],
};
myChart.setOption(option);
myChart2.setOption(option2);