-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.html
341 lines (317 loc) · 8.49 KB
/
index.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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Website</title>
<link rel="stylesheet" type="text/css" href="./static/css/zzsc-demo.css" />
<style>
.page {
display: flex;
flex-flow: column;
padding: 50px;
padding-top: 0;
align-items: center;
color: black;
background-color: #f2f2f2;
}
</style>
</head>
<body>
<!-- 页面主体容器 -->
<section class="page page1">
<h1>作品所属出版社分析</h1>
<div id="page1" style="width: 100%; height: 1000px; background-color: white"></div>
</section>
<section class="page page2">
<h1>作者著作量分析</h1>
<div id="page2" style="width: 100%; height: 1000px; background-color: white"></div>
</section>
<section class="page page3">
<h1>图书价格分析</h1>
<div id="page3" style="width: 100%; height: 1000px; background-color: white"></div>
</section>
<section class="page page4">
<h1>价格与热度相关性分析</h1>
<div id="page4" style="width: 100%; height: 1000px; background-color: white"></div>
</section>
<button id="downBtn" class="button button--view" aria-label="Show me more">
<svg width="100%" height="100%" viewBox="0 0 310 177" preserveAspectRatio="xMidYMid meet">
<path
fill="#FFFFFF"
d="M159.875,174.481L306.945,27.41c2.93-2.929,2.93-7.678,0-10.606L292.803,2.661c-1.406-1.407-3.314-2.197-5.303-2.197c-1.989,0-3.896,0.79-5.303,2.197L154.572,130.287L26.946,2.661c-1.406-1.407-3.314-2.197-5.303-2.197c-1.989,0-3.897,0.79-5.303,2.197L2.197,16.804C0.733,18.269,0,20.188,0,22.107s0.732,3.839,2.197,5.303l147.071,147.071C152.197,177.411,156.945,177.411,159.875,174.481L159.875,174.481z"
/>
</svg>
</button>
</body>
<!-- 翻页依赖 -->
<script src="./static/js/jquery-2.1.1.min.js" type="text/javascript"></script>
<script src="./static/js/naiveScroll.min.js"></script>
<!-- 翻页代码 -->
<script>
$(document).ready(function () {
$(this)._naiveScroll.init()
$('#downBtn').click(function () {
$(this)._naiveScroll.triggerScroll(-100)
})
})
</script>
<!-- 从后台读入数据 -->
<script src="./data/data.js"></script>
<!-- chart依赖 -->
<script src="https://cdn.bootcss.com/echarts/4.2.1-rc1/echarts.min.js"></script>
<!-- chart设置 -->
<!-- page1 作品所属出版社分析 -->
<script type="text/javascript">
{
// console.log(publisherData)
let data = []
let otherCount = 0
for (let key in publisherData) {
if (publisherData[key] > 20) {
data.push({
name: key,
value: publisherData[key],
})
} else otherCount += publisherData[key]
}
data.push({
name: '其他',
value: otherCount,
})
let myChart = echarts.init(document.getElementById('page1'))
let option = {
tooltip: {
trigger: 'item',
formatter: '{a} <br/>{b} : {c} ({d}%)',
},
legend: {
type: 'scroll',
orient: 'vertical',
right: 10,
top: 20,
bottom: 20,
data: data.legendData,
selected: {
未知: false,
其他: false,
},
},
series: [
{
name: '出版社',
type: 'pie',
radius: '55%',
center: ['40%', '50%'],
data,
itemStyle: {
emphasis: {
shadowBlur: 10,
shadowOffsetX: 0,
shadowColor: 'rgba(0, 0, 0, 0.5)',
},
},
},
],
}
myChart.setOption(option)
}
</script>
<!-- page2 -->
<script type="text/javascript">
{
let categoryData = []
let valueData = []
let temp = []
for (let key in authorData) {
if (key !== '作者未知') {
if (authorData[key] > 3) {
temp.push({
name: key.length > 50 ? key.substr(0, 50) + '…' : key,
num: authorData[key],
})
}
}
}
Array.prototype.sort.call(temp, (a, b) => a.num - b.num)
console.log(temp)
for (let item of temp) {
categoryData.push(item.name)
valueData.push(item.num)
}
let myChart = echarts.init(document.getElementById('page2'))
let option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
},
grid: {
left: '3%',
right: '4%',
bottom: '3%',
containLabel: true,
},
xAxis: {
type: 'value',
boundaryGap: [0, 0.01],
},
yAxis: {
type: 'category',
data: categoryData,
},
series: [
{
// name: '2011年',
type: 'bar',
data: valueData,
},
],
}
myChart.setOption(option)
}
</script>
<!-- page3 -->
<script type="text/javascript">
// 基于准备好的dom,初始化echarts实例
{
// console.log(priceData)
let categoryData = []
let valueData = []
for (let key in priceData) {
// console.log(key)
categoryData.push(+key)
valueData.push(priceData[key])
}
// console.log(categoryData)
let myChart = echarts.init(document.getElementById('page3'))
let option = {
toolbox: {
feature: {
dataZoom: {
yAxisIndex: false,
},
saveAsImage: {
pixelRatio: 2,
},
},
},
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
},
grid: {
bottom: 90,
},
dataZoom: [
{
type: 'inside',
},
{
type: 'slider',
},
],
xAxis: {
data: categoryData,
silent: false,
splitLine: {
show: false,
},
splitArea: {
show: false,
},
},
yAxis: {
splitArea: {
show: false,
},
},
series: [
{
type: 'bar',
data: valueData,
// Set `large` for large data amount
large: true,
},
],
}
myChart.setOption(option)
}
</script>
<!-- page4 价格与热度相关性分析 -->
<script type="text/javascript">
{
let data = price_commentData
let myChart = echarts.init(document.getElementById('page4'))
let option = {
backgroundColor: new echarts.graphic.RadialGradient(0.3, 0.3, 0.8, [
{
offset: 0,
color: '#f7f8fa',
},
{
offset: 1,
color: '#cdd0d5',
},
]),
title: {
subtext: '已去除极大值与极小值',
},
xAxis: {
splitLine: {
lineStyle: {
type: 'dashed',
},
},
},
yAxis: {
splitLine: {
lineStyle: {
type: 'dashed',
},
},
scale: true,
},
series: [
{
data,
type: 'scatter',
symbolSize: (data) => Math.sqrt(data[2]) / 10,
label: {
emphasis: {
show: true,
formatter: function (param) {
// 这里是点的名字
return param.data[3]
},
position: 'top',
},
},
itemStyle: {
normal: {
shadowBlur: 10,
shadowColor: 'rgba(120, 36, 50, 0.5)',
shadowOffsetY: 5,
color: new echarts.graphic.RadialGradient(0.4, 0.3, 1, [
{
offset: 0,
color: 'rgb(251, 118, 123)',
},
{
offset: 1,
color: 'rgb(204, 46, 72)',
},
]),
},
},
},
],
}
myChart.setOption(option)
}
</script>
</html>