Skip to content

Instantly share code, notes, and snippets.

@ix4
Forked from badosa/index.html
Created September 13, 2019 13:43
Show Gist options
  • Save ix4/b703fb1bcee29431974762de412e6d30 to your computer and use it in GitHub Desktop.
Save ix4/b703fb1bcee29431974762de412e6d30 to your computer and use it in GitHub Desktop.
EU vs US
<!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 -->
<!-- github.io and json-stat.org ARE NOT CDNs! Link to your own copies or to a CDN. -->
<link href="https://idescat.github.io/visual/visual.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.jsdelivr.net/npm/jsonstat@latest/json-stat.js"></script>
<script src="https://idescat.github.io/visual/lazyvisualsetup.js"></script>
<!-- /DO NOT DO THIS IN PRODUCTION -->
</head>
<body>
<div id="visual" class="visual"></div>
<script>
var
//tesem120: Unemployment rate
url="https://ec.europa.eu/eurostat/wdds/rest/data/v2.1/json/en/tesem120?sex=T&precision=1&age=TOTAL&s_adj=NSA",
eu={
label: "European Union (28)",
geo: "EU28",
val: []
},
us={
label: "United States",
geo: "US",
val: []
}
;
JSONstat(url, function(){
var
ds=this.Dataset( 0 ),
time=ds.Dimension( "time" ).id
;
time.forEach(function(t){
eu.val.push( ds.Data( { "time": t, "geo": eu.geo } ).value );
us.val.push( ds.Data( { "time": t, "geo": us.geo } ).value );
});
visual({
lang: "en",
title: "Unemployment rate: EU <i>vs</i> US",
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: us.label, val: us.val }
]
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment