-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
75 lines (75 loc) · 2.03 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
</head>
<body>
<div id="vis"/>
<script>
const spec = {
"data": {
"url": "https://raw.githubusercontent.com/sz0314/life_expansion/main/averaged_features_by_country.csv"
},
"vconcat": [
{
"mark": "bar",
"title": "Top 20 Countries for Life Expectancy",
"width": 300,
"height": 400,
"transform": [
{"filter": {"field": "Life_Expectancy", "valid": true}},
{
"window": [{"op": "rank", "as": "rank"}],
"sort": [{"field": "Life_Expectancy", "order": "descending"}]
},
{"filter": {"field": "rank", "lte": 20}}
],
"encoding": {
"x": {
"field": "Life_Expectancy",
"type": "quantitative",
"scale": {"domain": [80, 83], "clamp": true},
"axis": {"title": "Life Expectancy"},
"title": "Life Expectancy"
},
"y": {
"field": "Country Name",
"type": "nominal",
"sort": {
"op": "mean",
"field": "Life_Expectancy",
"order": "descending"
},
"axis": {"title": "Country"}
}
}
},
{
"mark": "bar",
"title": "Life Expectancy Histogram for All Countries",
"width": 300,
"height": 300,
"transform": [{"filter": {"field": "Life_Expectancy", "valid": true}}],
"encoding": {
"x": {
"field": "Life_Expectancy",
"type": "quantitative",
"bin": {"maxbins": 20},
"axis": {"title": "Life Expectancy"}
},
"y": {
"aggregate": "count",
"type": "quantitative",
"axis": {"title": "Count"}
}
}
}
],
"config": {}
};
vegaEmbed("#vis", spec, {mode: "vega-lite"}).then(console.log).catch(console.warn);
</script>
</body>
</html>