Skip to content

Instantly share code, notes, and snippets.

@badosa
Last active March 20, 2021 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badosa/d41084140fe9a466895a to your computer and use it in GitHub Desktop.
Save badosa/d41084140fe9a466895a to your computer and use it in GitHub Desktop.
Danish Unemployment by Sex
<!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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment