In this example, data is retrieved from Eurostat in the JSON-stat format, processed with the JSON-stat Javascript Toolkit and visualized with Idescat Visual.
Last active
September 30, 2022 16:23
-
-
Save badosa/bf052279a4dd5c35bd11 to your computer and use it in GitHub Desktop.
EU vs Germany
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<!--[if lt IE 7]><html class="lt-ie9 lt-ie8 lt-ie7"> <![endif]--> | |
<!--[if IE 7]><html class="lt-ie9 lt-ie8"> <![endif]--> | |
<!--[if IE 8]><html class="lt-ie9"> <![endif]--> | |
<!--[if gt IE 8]><!--> <html> <!--<![endif]--> | |
<head> | |
<title>Visual + JSON-stat: simple line chart</title> | |
<!-- DO NOT DO THIS IN PRODUCTION --> | |
<!-- js.org and json-stat.org ARE NOT CDNs! Link to your own copies or to a CDN. --> | |
<link href="https://visual.js.org/visual.css" rel="stylesheet" type="text/css" /> | |
<script src="https://visual.js.org/lazyvisualsetup.js"></script> | |
<!-- /DO NOT DO THIS IN PRODUCTION --> | |
<script src="https://unpkg.com/jsonstat-toolkit@1.4.2"></script> | |
</head> | |
<body> | |
<div id="visual" class="visual"></div> | |
<script> | |
var | |
//tesem120: Unemployment rate | |
url="https://ec.europa.eu/eurostat/api/dissemination/statistics/1.0/data/tesem120?sex=T&age=Y15-74&unit=PC_ACT&lang=EN", | |
eu={ | |
label: "European Union", | |
geo: "EU27_2020", | |
val: [] | |
}, | |
de={ | |
label: "Germany", | |
geo: "DE", | |
val: [] | |
} | |
; | |
JSONstat(url).then(function(ds){ | |
var time=ds.Dimension( "time" ).id; | |
console.log(ds); | |
time.forEach(function(t){ | |
eu.val.push( ds.Data( { "time": t, "geo": eu.geo } ).value ); | |
de.val.push( ds.Data( { "time": t, "geo": de.geo } ).value ); | |
}); | |
visual({ | |
lang: "en", | |
title: "Unemployment rate: EU <i>vs</i> Germany", | |
time: time, | |
footer: "Source: Eurostat.", | |
unit: { label: "%" }, | |
dec: 1, | |
range: [0, 15], | |
grid: { | |
line: 5, | |
shadow: 6, | |
point: 0 | |
}, | |
type: "tsline", | |
data: [ | |
{ label: eu.label, val: eu.val }, | |
{ label: de.label, val: de.val } | |
] | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment