-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
304 lines (230 loc) · 10.2 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
<!doctype html>
<html lang="zh-CN">
<head>
<!-- 必须的 meta 标签 -->
<meta charset="utf-8">
<title>EVE国服手游价格</title>
<script src="./assets/js/echarts.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script src="https://code.highcharts.com/modules/accessibility.js"></script>
<style>
#navbar {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 90px;
/* background-color: blue; */
transition: top 0.3s;
padding: .0 0;
background-color: transparent;
background-image: linear-gradient(to bottom, rgba(var(--bd-violet-rgb), 1), rgba(var(--bd-violet-rgb), 0.95));
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15), inset 0 -1px 0 rgba(0, 0, 0, 0.15);
}
:root {
/* --bd-violet-rgb: 112.520718,44.062154,249.437846; */
--bd-violet-rgb: 255, 201, 36;
}
.highcharts-figure,
.highcharts-data-table table {
min-width: 360px;
max-width: 800px;
/* margin: 1em auto; */
}
.highcharts-data-table table {
font-family: Verdana, sans-serif;
border-collapse: collapse;
border: 1px solid #ebebeb;
margin: 10px auto;
text-align: center;
width: 100%;
max-width: 500px;
}
.highcharts-data-table caption {
padding: 1em 0;
font-size: 1.2em;
color: #555;
}
.highcharts-data-table th {
font-weight: 600;
padding: 0.5em;
}
.highcharts-data-table td,
.highcharts-data-table th,
.highcharts-data-table caption {
padding: 0.5em;
}
.highcharts-data-table thead tr,
.highcharts-data-table tr:nth-child(even) {
background: #f8f8f8;
}
.highcharts-data-table tr:hover {
background: #f1f7ff;
}
</style>
</head>
<script>
var prevScrollpos = window.pageYOffset;
window.onscroll = function () {
var currentScrollPos = window.pageYOffset;
if (prevScrollpos > currentScrollPos) {
document.getElementById("navbar").style.top = "0";
} else {
document.getElementById("navbar").style.top = "-100px";
}
prevScrollpos = currentScrollPos;
}
</script>
<body>
<!-- 一个下滑就会向上隐藏的的顶部标题颜色块 -->
<div id="navbar">
<nav>
<ul style="padding: 0; margin: 0;">
<li style="padding: 5px 5px 40px 40px; margin: 0;"><a href=""><img src="./assets/sign.jpg" width="80"
height="80" style="border-radius: 50%;"></a></li>
</ul>
</nav>
</div>
<!-- 这里是页面内容 -->
<div id="content" style="margin-top: 100px;">
<figure class="highcharts-figure">
<div id="container"></div>
<p class="highcharts-description">
</p>
</figure>
<table id="demoTable"></table>
</div>
</body>
<script>
// csv获取
// 获取assets目录下所有文件名
var files_name = [];
var time_data_csv_data = {};
var data_csv_data = [];
const xhr = new XMLHttpRequest();
xhr.open('GET', 'data/', true);
xhr.onload = function () {
if (xhr.status === 200) {
_files_name = xhr.response.split('\n').filter(function (file) {
return file.trim() !== '' && file.trim().includes('<span class="name">') && !file.trim().includes('<ul');
});
console.log(_files_name); //<span class="name">2023_07_14_21_40_17_物品价格.csv</span>
_files_name.forEach(s1 => {
const regex = /<span class="name">([^<]+)<\/span>/;
const match = regex.exec(s1);
const text = match[1]; // "2023_07_15_08_53_53_物品价格.csv"
files_name.push(text); // ["2023_07_15_08_53_53_物品价格.csv", "2023_07_
// 读取csv
let table = document.getElementById("demoTable");
let file = './data/' + text;
let _s1 = text.replace(/_/g,"");
console.log(_s1);
// var _s1_time = _s1.substring(0, 4) + "/" + _s1.substring(4, 6) + "/" + _s1.substring(6, 8) + " " + _s1.substring(8, 10) + ":" + _s1.substring(10, 12)+ ":" + _s1.substring(12, 14);
var _s1_time = parseInt(_s1.substring(0, 14));
if (time_data_csv_data['time'] === null || time_data_csv_data['time'] === undefined){
time_data_csv_data['time'] = [];
}
time_data_csv_data['time'].push(_s1_time);
fetch(file)
.then((res) => { return res.text(); })
.then((csv) => {
// (B1) REMOVE OLD TABLE ROWS
table.innerHTML = "";
// (B2) GENERATE TABLE
csv = csv.split("\r\n");
for (let row of csv) {
let tr = table.insertRow();
for (let col of row.split(",")) {
let td = tr.insertCell();
td.innerHTML = col;
}
}
// csv = csv.split("\r\n");
for (let row of csv) {
_row0 = row.split(",")[0];
if (_row0 !== "名称"){
if (time_data_csv_data[_row0] === null || time_data_csv_data[_row0] === undefined){
time_data_csv_data[_row0] = [];
}
time_data_csv_data[_row0].push(parseInt(row.split(",")[1])); // {名称: 价格}
}
}
})
.then((AAAAAA) =>{
// console.log(files_name);
let _t = Object.assign(time_data_csv_data) ;
console.log(_t);
for (let _key in _t) {
// console.log(_key + ': ' + _t[_key]);
if (_key !== "time"){
let obj = {};
obj["name"] = _key;
obj["data"] = _t[_key];
data_csv_data.push(obj);
}
}
// let data_csv_data = _t;
console.log(time_data_csv_data);
console.log(time_data_csv_data["time"]);
// 表格
Highcharts.dateFormat("%Y/%m/%d %H:%M:%S", 20, true);
Highcharts.chart('container', {
title: {
text: '总表',
align: 'left'
},
/**subtitle: {
text: 'By Job Category. Source: <a href="https://irecusa.org/programs/solar-jobs-census/" target="_blank">IREC</a>.',
align: 'left'
},**/
yAxis: {
title: {
text: '价格(isk)'
}
},
xAxis: {
type: 'datetime',
dateFormat: "%Y/%m/%d %H:%M:%S",
categories: time_data_csv_data["time"]
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle'
},
/*plotOptions: {
series: {
label: {
connectorAllowed: false
},
pointStart: 2010
}
},*/
series: data_csv_data,
responsive: {
rules: [{
condition: {
// maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
});
});
}
};
xhr.send();
</script>
<script>
</script>
</html>