-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcovid.html
544 lines (462 loc) · 18.8 KB
/
covid.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
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
<html>
<head>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-167462362-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-167462362-1');
</script>
<title>COVID-19 Інфографіка</title>
<meta charset="utf-8">
<meta name="description" content="COVID-19 Інфографіка для України, Області України, Таймлайн, Смертність / Одужання, Тенденція захворювання">
<meta name="keywords" content="COVID, COVID-19, Україна, коронавірус">
<meta name="author" content="John Doe">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://www.amcharts.com/lib/4/core.js" crossorigin="anonymous"></script>
<script src="https://www.amcharts.com/lib/4/charts.js" crossorigin="anonymous"></script>
<script src="https://www.amcharts.com/lib/4/maps.js" crossorigin="anonymous"></script>
<script src="https://www.amcharts.com/lib/4/geodata/data/countries2.js" crossorigin="anonymous"></script>
<script src="https://www.amcharts.com/lib/4/themes/animated.js" crossorigin="anonymous"></script>
<script src="//www.amcharts.com/lib/4/themes/material.js" crossorigin="anonymous"></script>
</head>
<body>
<style>
@font-face {
font-family: "Comfortaa";
src: url("fonts/Comfortaa/Comfortaa-VariableFont_wght.ttf");
}
html, body {
font-family: 'Comfortaa', Arial, sans-serif;
font-weight:normal;
font-style:normal;
margin: 0;
}
#області{
margin:0;
padding: 10px;
background-color: #f5f5f5;
}
#chartdiv {
width: 100%;
max-width: 960px;
max-height: 600px;
margin: auto;
height: calc(100% - 205px);
}
#таймлайн{
margin:0;
padding: 10px;
background-color: rgb(198, 237, 255);
}
#chartdiv2 {
margin: auto;
width: 100%;
max-height: 700px;
max-width: 1260px;
height: calc(100% - 180px);
}
#випадки {
margin:0;
padding: 10px;
background-color: rgb(238, 230, 255)
}
#chartdiv3 {
width: 100%;
height: calc(100% - 180px);
max-width: 960px;
margin: auto;
}
#тенденція {
margin:0;
padding: 10px;
background-color: rgb(245, 226, 179)
}
#chartdiv4 {
width: 100%;
height: calc(100% - 180px);
margin: auto;
max-width: 960px;
}
</style>
<script>
am4core.ready(function() {
jQuery.ajaxSetup({ cache: false });
window.onload = function() {
am4core.useTheme(am4themes_animated);
am4core.useTheme(am4themes_material);
/**
* This demo uses our own method of determining user's location
* It is not public web service that you can use
* You'll need to find your own. We recommend http://www.maxmind.com
*/
// jQuery.getJSON( "https://www.amcharts.com/tools/country/?v=xz6Z", function( geo ) {
var geo = {
country_code: "UA",
country_name: "Ukraine"
}
// Default map
var defaultMap = "usaAlbersLow";
// calculate which map to be used
var currentMap = defaultMap;
var title = "";
if ( am4geodata_data_countries2[ geo.country_code ] !== undefined ) {
currentMap = am4geodata_data_countries2[ geo.country_code ][ "maps" ][ 0 ];
// add country title
if ( am4geodata_data_countries2[ geo.country_code ][ "country" ] ) {
title = am4geodata_data_countries2[ geo.country_code ][ "country" ];
}
}
// Create map instance
var chart = am4core.create("chartdiv", am4maps.MapChart);
// chart.titles.create().text = title;
// Set map definition
chart.seriesContainer.draggable = false;
chart.seriesContainer.resizable = false;
chart.maxZoomLevel = 1;
chart.chartContainer.wheelable = false;
// chart.seriesContainer.events.disableType("doublehit");
// chart.chartContainer.background.events.disableType("doublehit");
chart.geodataSource.url = "data/ukraine-low-poli.json";
chart.geodataSource.events.on("parseended", function(ev) {
jQuery.getJSON( "data/data.json", function( geo ) {
polygonSeries.data = geo;
});
})
// Set projection
chart.projection = new am4maps.projections.Mercator();
// Create map polygon series
var polygonSeries = chart.series.push(new am4maps.MapPolygonSeries());
//Set min/max fill color for each area
polygonSeries.heatRules.push({
property: "fill",
target: polygonSeries.mapPolygons.template,
min: chart.colors.getIndex(18).brighten(1),
max: chart.colors.getIndex(18).brighten(-0.65)
});
// Make map load polygon data (state shapes and names) from GeoJSON
polygonSeries.useGeodata = true;
// Set up heat legend
let heatLegend = chart.createChild(am4maps.HeatLegend);
heatLegend.series = polygonSeries;
heatLegend.align = "left";
heatLegend.width = am4core.percent(20);
heatLegend.marginLeft = am4core.percent(6);
heatLegend.marginBottom = am4core.percent(20);
heatLegend.minValue = 0;
heatLegend.maxValue = 40000000;
heatLegend.valign = "bottom";
heatLegend.fontSize = 9;
// Set up custom heat map legend labels using axis ranges
var minRange = heatLegend.valueAxis.axisRanges.create();
minRange.value = heatLegend.minValue;
minRange.label.text = "Низький";
var maxRange = heatLegend.valueAxis.axisRanges.create();
maxRange.value = heatLegend.maxValue;
maxRange.label.text = "Високий";
// Blank out internal heat legend value axis labels
heatLegend.valueAxis.renderer.labels.template.adapter.add("text", function(labelText) {
return "";
});
// Configure series tooltip
var polygonTemplate = polygonSeries.mapPolygons.template;
polygonTemplate.tooltipText = "{name}: {value}";
polygonTemplate.nonScalingStroke = true;
polygonTemplate.strokeWidth = 0.5;
// Create hover state and set alternative fill color
var hs = polygonTemplate.states.create("hover");
hs.properties.fill = chart.colors.getIndex(6).brighten(-0.5);
// });
};
}); // end am4core.ready()
</script>
<script>
const startDate = "2020-04-04";
Date.prototype.addDays = function(days) {
var date = new Date(this.valueOf());
date.setDate(date.getDate() + days);
return date;
}
am4core.ready(function() {
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
var chart = am4core.create("chartdiv2", am4charts.XYChart);
chart.padding(40, 40, 40, 40);
chart.numberFormatter.bigNumberPrefixes = [
// { "number": 1e+3, "suffix": "K" },
// { "number": 1e+6, "suffix": "M" },
// { "number": 1e+9, "suffix": "B" }
];
var label = chart.plotContainer.createChild(am4core.Label);
label.x = am4core.percent(97);
label.y = am4core.percent(95);
label.horizontalCenter = "right";
label.verticalCenter = "middle";
label.dx = -15;
label.fontSize = 50;
var playButton = chart.plotContainer.createChild(am4core.PlayButton);
playButton.x = am4core.percent(97);
playButton.y = am4core.percent(95);
playButton.dy = -2;
playButton.verticalCenter = "middle";
playButton.events.on("toggled", function(event) {
if (event.target.isActive) {
play();
}
else {
stop();
}
})
var stepDuration = 100;
var categoryAxis = chart.yAxes.push(new am4charts.CategoryAxis());
categoryAxis.renderer.grid.template.location = 0;
categoryAxis.dataFields.category = "name";
categoryAxis.renderer.minGridDistance = 1;
categoryAxis.renderer.inversed = true;
categoryAxis.renderer.grid.template.disabled = true;
var valueAxis = chart.xAxes.push(new am4charts.ValueAxis());
valueAxis.min = 0;
valueAxis.rangeChangeEasing = am4core.ease.linear;
valueAxis.rangeChangeDuration = stepDuration;
valueAxis.extraMax = 0.1;
var series = chart.series.push(new am4charts.ColumnSeries());
series.dataFields.categoryY = "name";
series.dataFields.valueX = "value";
series.tooltipText = "{valueX.value}"
series.columns.template.strokeOpacity = 0;
series.columns.template.column.cornerRadiusBottomRight = 5;
series.columns.template.column.cornerRadiusTopRight = 5;
series.interpolationDuration = stepDuration;
series.interpolationEasing = am4core.ease.linear;
var labelBullet = series.bullets.push(new am4charts.LabelBullet())
labelBullet.label.horizontalCenter = "right";
labelBullet.label.text = "{values.valueX.workingValue.formatNumber('#,###.as')}";
labelBullet.label.textAlign = "end";
labelBullet.label.dx = -10;
labelBullet.label.fontSize = 12;
labelBullet.label.paddingTop = 2;
chart.zoomOutButton.disabled = true;
// as by default columns of the same series are of the same color, we add adapter which takes colors from chart.colors color set
series.columns.template.adapter.add("fill", function(fill, target){
return chart.colors.getIndex(target.dataItem.index);
});
var pre_date = new Date(startDate);
var date = new Date(Date.UTC(pre_date.getUTCFullYear(),pre_date.getUTCMonth(), pre_date.getUTCDate(), pre_date.getUTCHours(), pre_date.getUTCMinutes(), pre_date.getUTCSeconds(), pre_date.getUTCMilliseconds()))
label.text = date.toLocaleDateString()
var interval;
function play() {
interval = setInterval(function(){
nextYear();
}, stepDuration)
nextYear();
}
function stop() {
if (interval) {
clearInterval(interval);
}
}
function nextYear() {
date = date.addDays(1);
console.log(date)
if (date.getTime() > Date.now()) {
stop()
return;
}
var newData = allData[date.getTime()];
if(newData == undefined) {
return
}
var itemsWithNonZero = 0;
console.log(chart.data.length)
console.log(newData)
for (var i = 0; i < chart.data.length; i++) {
chart.data[i].value = newData[i].value;
if (chart.data[i].value > 0) {
itemsWithNonZero++;
}
}
if (date.getTime() == new Date(startDate).getTime()) {
series.interpolationDuration = stepDuration / 4;
valueAxis.rangeChangeDuration = stepDuration / 4;
}
else {
series.interpolationDuration = stepDuration;
valueAxis.rangeChangeDuration = stepDuration;
}
chart.invalidateRawData();
label.text = date.toLocaleDateString()
categoryAxis.zoom({ start: 0, end: itemsWithNonZero / categoryAxis.dataItems.length });
}
categoryAxis.sortBySeries = series;
var allData = {};
jQuery.getJSON('data/race-auto.json', function(data) {
allData = data;
chart.data = JSON.parse(JSON.stringify(allData[date.getTime()]));
categoryAxis.zoom({ start: 0, end: 1 / chart.data.length });
series.events.on("inited", function() {
setTimeout(function() {
playButton.isActive = true; // this starts interval
}, 2000)
})
});
}); // end am4core.ready()
</script>
<script>
am4core.ready(function() {
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
// Create chart instance
var chart = am4core.create("chartdiv3", am4charts.XYChart3D);
// Add data
jQuery.getJSON('data/experiments.json', function(data) {
chart.data = data;
});
// Create axes
var categoryAxis = chart.xAxes.push(new am4charts.CategoryAxis());
categoryAxis.dataFields.category = "country";
categoryAxis.renderer.labels.template.rotation = 0;
categoryAxis.renderer.labels.template.hideOversized = true;
categoryAxis.renderer.minGridDistance = 20;
categoryAxis.renderer.labels.template.horizontalCenter = "right";
categoryAxis.renderer.labels.template.verticalCenter = "middle";
// categoryAxis.tooltip.label.rotation = 270;
categoryAxis.cursorTooltipEnabled = false;
// categoryAxis.tooltip.label.horizontalCenter = "right";
// categoryAxis.tooltip.label.verticalCenter = "middle";
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
valueAxis.title.text = "Осіб";
valueAxis.title.fontWeight = "bold";
// Create series
var series = chart.series.push(new am4charts.ColumnSeries3D());
series.dataFields.valueY = "visits";
series.dataFields.categoryX = "country";
series.name = "Visits";
series.tooltipText = "{categoryX}: [bold]{valueY}[/]";
series.columns.template.fillOpacity = .8;
series.columns.template.propertyFields.fill = "color";
var columnTemplate = series.columns.template;
columnTemplate.strokeWidth = 2;
columnTemplate.strokeOpacity = 1;
columnTemplate.stroke = am4core.color("#FFFFFF");
chart.cursor = new am4charts.XYCursor();
chart.cursor.lineX.strokeOpacity = 0;
chart.cursor.lineY.strokeOpacity = 0;
// Enable export
// chart.exporting.menu = new am4core.ExportMenu();
}); // end am4core.ready()
</script>
<script>
am4core.ready(function() {
// Themes begin
am4core.useTheme(am4themes_animated);
// Themes end
var chart = am4core.create("chartdiv4", am4charts.XYChart);
jQuery.getJSON( "data/tendentious.json", function( data ) {
chart.data = data;
});
// Create axes
var dateAxis = chart.xAxes.push(new am4charts.DateAxis());
dateAxis.renderer.minGridDistance = 60;
var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
// Create series
var series = chart.series.push(new am4charts.LineSeries());
series.dataFields.valueY = "value";
series.dataFields.dateX = "date";
series.tooltipText = "{value}"
series.tooltip.pointerOrientation = "vertical";
chart.cursor = new am4charts.XYCursor();
chart.cursor.snapToSeries = series;
chart.cursor.xAxis = dateAxis;
//chart.scrollbarY = new am4core.Scrollbar();
// chart.scrollbarX = new am4core.Scrollbar();
}); // end am4core.ready()
</script>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
background-color: #333333;
}
li {
float: left;
width: 50%;
}
li a {
display: block;
color: white;
text-align: center;
padding-top: 31px;
padding-bottom: 31px;
margin: auto;
text-decoration: none;
}
li a:hover {
background-color: #111111;
}
@media all and (max-width: 768px) {
li {
font-size: 12px
}
}
footer a:-webkit-any-link {
color: white;
}
</style>
<div id="header" style="position:fixed; top:0px; left:0px; height:80px; right:0px;overflow:hidden;z-index: 100">
<ul>
<li><a href="/infographic">Air Raid Map</a></li>
<li><a href="#">Covid-19</a></li>
<!-- <li><a href="#випадки">Випадки</a></li>-->
<!-- <li><a href="#тенденція">Тенденція</a></li>-->
</ul>
</div>
<div id="content" style="">
<div id="області" style="padding-top:80px">
<div style="text-align: center;">
<h1>COVID-19 Інфографіка</h1>
</div>
<div style="text-align: center;">
<h3>! Дані не актуальні !</h3>
</div>
<div id="chartdiv"></div>
</div>
<div id="таймлайн" style="padding-top:80px">
<div style="text-align: center; padding: 15px">
<h3>Таймлайн</h3>
</div>
<div id="chartdiv2"></div>
</div>
<div id="випадки" style="padding-top:80px">
<div style="text-align: center; padding: 15px">
<h3>Випадки смерті та одужання</h3>
</div>
<div id="chartdiv3"></div>
</div>
<div id="тенденція" style="padding-top:80px">
<div style="text-align: center; padding: 15px">
<h3>Тенденція захворювання</h3>
</div>
<div id="chartdiv4"></div>
</div>
</div>
<div id="footer" style="padding: 30px; background-color: #505050;color: #fff; font-size: 12px">
Інформацію взято з відкритих джерел.
<br>
Створено <a style="color:white" href="https://github.com/vergilet" target="_blank">Yaro</a>
</div>
<!--<script>-->
<!-- $("ul li a").click(function(e) {-->
<!-- e.preventDefault();-->
<!-- var aid = $(this).attr("href");-->
<!-- $('html,body').animate({scrollTop: $(aid).offset().top},'slow');-->
<!-- });-->
<!--</script>-->
</body>
</html>