Highcharts Demo
author(s): Pawel Potaczek
by Black Label
HTML
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container"></div>
JavaScript
const globalData = [];
let chart;
// Fetch data:
fetch('https://pomber.github.io/covid19/timeseries.json')
.then(response => response.json())
.then(data => {
parseData(data);
createChart();
});
function parseData(data) {
Highcharts.objectEach(
data,
// Prepare Highcharts data-format:
// series: [{
// data: [ [x, y], [x, y], ..., [x, y]]
// }]
(countryData, country) => globalData.push({
name: country,
data: countryData.map(p => [Date.parse(p.date), p.confirmed])
})
);
}
function createChart() {
chart = Highcharts.chart('container', {
title: {
text: 'Confirmed cases per country'
},
xAxis: {
type: 'datetime'
},
yAxis: {
title: ''
},
series: globalData
});
}