-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
419 lines (408 loc) · 16.8 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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Export XLSX Demo</title>
<script src="https://code.jquery.com/jquery-3.3.1.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.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://cdn.jsdelivr.net/npm/exceljs@latest/dist/exceljs.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/file-saver@latest/dist/FileSaver.min.js"></script>
<script src="https://cdn.statically.io/gh/SheetJS/ssf/e267d1d6/ssf.js"></script>
<script src="./js/export-xlsx.js"></script>
<link rel="stylesheet" href="./css/styles.css">
</head>
<body>
<div class="chart" id="chart-container-1"></div>
<div class="chart" id="chart-container-2"></div>
<div class="chart" id="chart-container-3"></div>
<div class="chart" id="chart-container-4"></div>
<div class="chart" id="chart-container-5"></div>
<script>
$(document).ready(function() {
var chartOptions1 = {
chart: {
zoomType: 'x'
},
exporting: {
filename: 'export_xlsx_example',
csv: {
// Test export-xlsx interface with columnHeaderFormatter function
// The column headers in the exported workbook should be as follows:
// FormatterName, Less than HS, HS, Some College Mod, Bachelor Degree & Higher Mod
columnHeaderFormatter: function(item, key) {
if (!item || item instanceof Highcharts.Axis) {
return item.options.title.text || 'FormatterName';
}
// Item is not axis, now we are working with series.
// Key is the property on the series we show in this column.
else {
return item.name + ' Mod';
}
}
},
xlsx: {
worksheet: {
autoFitColumns: true,
categoryColumn: {
numberFormat: 'yyyy-mm'
}
},
workbook: {
fileProperties: {
creator: "File Author",
company: "File Company",
created: new Date(2017, 11, 31)
}
}
}
},
title: {
text: 'US Unemployment Rates by Educational Attainment',
},
yAxis: {
title: {
text: 'Percent'
}
},
xAxis: {
type: 'datetime',
title: {
text: null
}
},
plotOptions: {
series: {
pointStart: Date.UTC(2007, 0, 1),
pointIntervalUnit: 'month',
marker: {
enabled: false
}
}
},
series: [{
index: 0,
zIndex: 3,
legendIndex: 0,
name: 'Less than High School',
xlsx: {
numberFormat: '0.0',
name: 'Less than HS'
},
data: [6.9, 7.3, 6.9, 7.1, 6.6, 6.7, 7.3, 6.5, 7.6, 7.3, 7.7, 7.7, 7.7, 7.4, 8.4, 7.7, 8.1, 8.7, 8.6, 9.7, 9.8, 10.3, 10.8, 11.1, 12.4, 13.2, 14.0, 14.9, 15.2, 15.6, 15.3, 15.6, 14.9, 15.2, 14.7, 15.0, 15.3, 15.8, 14.9, 14.7, 14.6, 14.2, 13.5, 14.1, 15.6, 15.0, 15.4, 15.0, 14.3, 14.0, 14.1, 14.7, 14.5, 14.4, 14.5, 14.1, 14.3, 13.5, 12.8, 13.7, 13.0, 13.1, 12.8, 12.5, 12.9, 12.6, 12.4, 11.8, 11.7, 12.1, 12.0, 11.8, 12.0, 11.3, 11.1, 11.6, 11.0, 10.7, 10.8, 11.1, 10.5, 10.9, 10.7, 9.8, 9.4, 9.8, 9.4, 8.7, 9.2, 9.2, 9.5, 9.2, 8.5, 8.1, 8.6, 8.6, 8.3, 8.2, 8.6, 8.5, 8.7, 8.2, 8.3, 7.9, 7.9, 7.6, 6.8, 6.5, 7.1, 7.0, 7.4, 7.6, 7.5, 7.6, 6.4, 7.4, 8.5, 7.5, 7.8, 7.6, 7.4, 7.6, 6.6, 6.4, 6.3, 6.5, 7.0, 6.1, 6.7, 6.0, 5.2, 6.3, 5.5, 5.6, 5.6, 5.8, 5.5, 5.6, 5.0, 5.7, 5.6, 5.9, 5.6, 5.8, 5.7]
}, {
index: 1,
zIndex: 2,
legendIndex: 1,
xlsx: {
numberFormat: '0',
name: 'HS'
},
name: 'High School',
data: [4.3, 4.3, 4.0, 4.1, 4.4, 4.1, 4.6, 4.4, 4.5, 4.6, 4.5, 4.7, 4.7, 4.7, 5.1, 5.0, 5.0, 5.1, 5.4, 5.8, 6.2, 6.4, 7.0, 7.8, 8.2, 8.5, 9.2, 9.5, 10.0, 9.7, 9.5, 9.7, 10.6, 11.0, 10.3, 10.6, 10.2, 10.7, 11.0, 10.8, 10.9, 10.6, 10.0, 10.0, 9.7, 9.8, 10.0, 9.8, 9.5, 9.7, 9.7, 9.9, 9.6, 10.0, 9.1, 9.3, 9.4, 9.4, 8.8, 8.7, 8.5, 8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, 4.2, 4.2, 4.2, 3.8, 4.2, 4.2, 4.2, 4.2, 3.9, 3.9, 3.8, 3.8, 4.0, 3.7, 3.7, 4.0, 3.8, 3.8, 3.7, 3.6, 3.7, 3.6, 3.6, 3.4, 3.5, 3.5, 3.4, 3.2, 3.3, 3.2, 3.5, 3.2, 3.0, 3.1, 3.3, 3.4]
}, {
index: 3,
zIndex: 1,
legendIndex: 3,
name: 'Bachelor Degree & Higher',
data: [2.1, 1.9, 1.8, 1.9, 2.0, 2.0, 2.1, 2.1, 2.0, 2.1, 2.2, 2.1, 2.1, 2.0, 2.1, 2.1, 2.2, 2.4, 2.5, 2.8, 2.6, 3.1, 3.2, 3.6, 3.9, 4.1, 4.3, 4.4, 4.8, 4.8, 4.8, 4.8, 5.0, 4.7, 4.8, 4.9, 4.9, 4.9, 4.9, 4.8, 4.6, 4.4, 4.5, 4.6, 4.5, 4.6, 5.0, 4.8, 4.3, 4.3, 4.4, 4.5, 4.5, 4.3, 4.2, 4.2, 4.2, 4.3, 4.4, 4.1, 4.3, 4.2, 4.1, 4.0, 3.9, 4.0, 4.1, 4.1, 4.0, 3.7, 3.9, 4.0, 3.8, 3.9, 3.8, 3.9, 3.9, 3.8, 3.8, 3.4, 3.7, 3.7, 3.4, 3.3, 3.3, 3.4, 3.4, 3.3, 3.2, 3.3, 3.1, 3.2, 2.9, 3.0, 3.2, 2.8, 2.8, 2.7, 2.4, 2.7, 2.8, 2.5, 2.5, 2.4, 2.5, 2.5, 2.6, 2.5, 2.5, 2.5, 2.6, 2.4, 2.5, 2.5, 2.5, 2.6, 2.5, 2.6, 2.4, 2.5, 2.5, 2.4, 2.4, 2.4, 2.3, 2.3, 2.3, 2.4, 2.3, 2.1, 2.1, 2.1, 2.2, 2.2, 2.2, 2.1, 2.0, 2.3, 2.2, 2.0, 2.0, 2.0, 2.2, 2.1, 2.4]
}]
};
var chart1 = new Highcharts.Chart('chart-container-1', chartOptions1);
// Chart 2 adapted from https://www.highcharts.com/demo/spline-plot-bands
var chartOptions2 = {
chart: {
type: 'spline',
zoomType: 'x'
},
exporting: {
filename: 'export_xlsx_example',
xlsx: {
worksheet: {
autoFitColumns: true,
sheetName: 'Wind Speed',
categoryColumn: {
numberFormat: 'm/d/yyyy h:mm AM/PM'
}
}
}
},
title: {
text: 'Wind speed during two days'
},
subtitle: {
text: '13th & 14th of February, 2018 at two locations in Vik i Sogn, Norway'
},
xAxis: {
type: 'datetime',
labels: {
overflow: 'justify'
}
},
yAxis: {
title: {
text: 'Wind speed (m/s)'
}
},
tooltip: {
valueSuffix: ' m/s'
},
plotOptions: {
spline: {
pointInterval: 3600000, // one hour
pointStart: Date.UTC(2018, 1, 13, 0, 0, 0),
marker: {
enabled: false
}
}
},
series: [{
name: 'Hestavollane',
data: [3.7, 3.3, 3.9, 5.1, 3.5, 3.8, 4.0, 5.0, 6.1, 3.7, 3.3, 6.4, 6.9, 6.0, 6.8, 4.4, 4.0, 3.8, 5.0, 4.9, 9.2, 9.6, 9.5, 6.3, 9.5, 10.8, 14.0, 11.5, 10.0, 10.2, 10.3, 9.4, 8.9, 10.6, 10.5, 11.1, 10.4, 10.7, 11.3, 10.2, 9.6, 10.2, 11.1, 10.8, 13.0, 12.5, 12.5, 11.3, 10.1]
}, {
name: 'Vik',
data: [0.2, 0.1, 0.1, 0.1, 0.3, 0.2, 0.3, 0.1, 0.7, 0.3, 0.2, 0.2, 0.3, 0.1, 0.3, 0.4, 0.3, 0.2, 0.3, 0.2, 0.4, 0.0, 0.9, 0.3, 0.7, 1.1, 1.8, 1.2, 1.4, 1.2, 0.9, 0.8, 0.9, 0.2, 0.4, 1.2, 0.3, 2.3, 1.0, 0.7, 1.0, 0.8, 2.0, 1.2, 1.4, 3.7, 2.1, 2.0, 1.5]
}]
};
var chart2 = new Highcharts.Chart('chart-container-2', chartOptions2);
// Chart 3 adapted from https://www.highcharts.com/demo/column-basic
var chartOptions3 = {
chart: {
type: 'column'
},
exporting: {
filename: 'export_xlsx_example',
xlsx: {
worksheet: {
sheetName: 'Monthly Rainfall',
categoryColumn: {
title: 'Month'
},
headerStyle: {
font: {
color: '#FFFFFF',
bold: true
},
fill: {
color: '#414b56'
}
}
}
}
},
title: {
text: 'Monthly Average Rainfall'
},
subtitle: {
text: 'Source: WorldClimate.com'
},
xAxis: {
categories: [
'Jan',
'Feb',
'Mar',
'Apr',
'May',
'Jun',
'Jul',
'Aug',
'Sep',
'Oct',
'Nov',
'Dec'
],
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Rainfall (mm)'
}
},
tooltip: {
headerFormat: '<span style="font-size:10px">{point.key}</span><table>',
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
'<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
footerFormat: '</table>',
shared: true,
useHTML: true
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'Tokyo',
xlsx: {
numberFormat: '0',
},
data: [49.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}, {
name: 'New York',
data: [83.6, 78.8, 98.5, 93.4, 106.0, 84.5, 105.0, 104.3, 91.2, 83.5, 106.6, 92.3]
}, {
name: 'London',
data: [48.9, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2]
}, {
name: 'Berlin',
data: [42.4, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1]
}]
};
var chart3 = new Highcharts.Chart('chart-container-3', chartOptions3);
// Chart 4 adapted from https://www.highcharts.com/demo/combo
var chartOptions4 = {
title: {
text: 'Combination chart'
},
xAxis: {
categories: ['Apples', 'Oranges', 'Pears', 'Bananas', 'Plums']
},
tooltip: {
formatter: function() {
var s;
if (this.point.name) { // the pie chart
s = '' +
this.point.name + ': ' + this.y + ' fruits';
} else {
s = '' +
this.x + ': ' + this.y;
}
return s;
}
},
labels: {
items: [{
html: 'Total fruit consumption',
style: {
left: '40px',
top: '8px',
color: 'black'
}
}]
},
series: [{
type: 'column',
name: 'Jane',
data: [3, 2, 1, 3, 4]
}, {
type: 'column',
name: 'John',
data: [2, 3, 5, 7, 6]
}, {
type: 'column',
name: 'Joe',
data: [4, 3, 3, 9, 0]
}, {
type: 'spline',
name: 'Average',
data: [3, 2.67, 3, 6.33, 3.33]
}, {
type: 'pie',
name: 'Total consumption',
data: [{
name: 'Jane',
y: 13,
color: '#4572A7' // Jane's color
}, {
name: 'John',
y: 23,
color: '#AA4643' // John's color
}, {
name: 'Joe',
y: 19,
color: '#89A54E' // Joe's color
}],
center: [100, 80],
size: 100,
showInLegend: false,
dataLabels: {
enabled: false
}
}]
};
var chart4 = new Highcharts.Chart('chart-container-4', chartOptions4);
// Chart 5 adapted from https://www.highcharts.com/demo/pie-basic
var chartOptions5 = {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie'
},
title: {
text: 'Browser market shares in January, 2018'
},
tooltip: {
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
accessibility: {
point: {
valueSuffix: '%'
}
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b>: {point.percentage:.1f} %'
}
}
},
series: [{
name: 'Brands',
colorByPoint: true,
xlsx: {
numberFormat: '0.0'
},
data: [{
name: 'Chrome',
y: 61.41,
sliced: true,
selected: true
}, {
name: 'Internet Explorer',
y: 11.84
}, {
name: 'Firefox',
y: 10.85
}, {
name: 'Edge',
y: 4.67
}, {
name: 'Safari',
y: 4.18
}, {
name: 'Sogou Explorer',
y: 1.64
}, {
name: 'Opera',
y: 1.6
}, {
name: 'QQ',
y: 1.2
}, {
name: 'Other',
y: 2.61
}]
}]
};
var chart5 = new Highcharts.Chart('chart-container-5', chartOptions5);
});
</script>
</body>
</html>