Statistics Denmark supports the JSON-stat format. In this example, data is retrieved using the Danish API, processed with the JSON-stat Javascript Toolkit and finally visualized with Idescat Visual.
Check also this similar example.
Statistics Denmark supports the JSON-stat format. In this example, data is retrieved using the Danish API, processed with the JSON-stat Javascript Toolkit and finally visualized with Idescat Visual.
Check also this similar example.
<!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> | |
<meta charset="utf-8" /> | |
<title>Visual + JSON-stat: simple line chart</title> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> | |
<!-- DO NOT DO THIS IN PRODUCTION --> | |
<!-- github.io 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://cdn.jsdelivr.net/npm/jsonstat@0.13.13"></script> | |
<script src="https://visual.js.org/lazyvisualsetup.js"></script> | |
<!-- /DO NOT DO THIS IN PRODUCTION --> | |
</head> | |
<body> | |
<section id="visual" class="visual"></section> | |
<script> | |
var url="https://api.statbank.dk/v1/data/AKU110K/JSONSTAT?lang=en&valuePresentation=Default&timeOrder=Ascending&Tid=(-n%2B41)&K%C3%98N=M%2CK&BESKSTATUS=AKUL"; | |
JSONstat(url, function(){ | |
//"Tid" contains time; "KØN", sex | |
var | |
ds=this.Dataset(0), | |
tid=ds.Dimension("Tid").id, | |
time=[], | |
men=[], | |
women=[] | |
; | |
tid.forEach(function(t){ | |
var | |
//men | |
m=ds.Data({"Tid": t, "KØN": "M"}).value*1000, | |
//women | |
w=ds.Data({"Tid": t, "KØN": "K"}).value*1000 | |
; | |
time.push(t.replace(/K/,"")); //Normalize time for Visual | |
men.push(m); | |
women.push(w); | |
}); | |
visual({ | |
lang: "en", | |
title: "Unemployment by sex", | |
geo: "Denmark", | |
time: time, | |
footer: "Source: Statistics Denmark.", | |
unit: {label: "people"}, | |
dec: 0, | |
range: [40000,160000], | |
grid: { | |
line: 5, | |
shadow: 6, | |
point: 0 | |
}, | |
type: "tsline", | |
data: [ | |
{ label: "Men", val: men }, | |
{ label: "Women", val: women } | |
] | |
}); | |
}); | |
</script> | |
</body> | |
</html> |