-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
102 lines (100 loc) · 2.63 KB
/
index.html
File metadata and controls
102 lines (100 loc) · 2.63 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Per Capita Energy Consumption by Australian State</title>
<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"></div>
<script type="text/javascript">
var spec =
{
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"title": {
"text": "Per Capita Energy Consumption by Australian State in 2024",
"fontSize": 18,
"fontWeight": "bold",
"anchor": "start",
"color": "black"
},
"width": 600,
"height": 550,
"layer": [
{
"data": {
"url": "https://raw.githubusercontent.com/RyhanJ/Week9Homework/refs/heads/main/au-states-topo.json",
"format": {
"type": "topojson",
"feature": "austates"
}
},
"transform": [
{
"lookup": "id",
"from": {
"data": {
"url": "https://raw.githubusercontent.com/RyhanJ/Week9Homework/refs/heads/main/australian_energy_consumption_by_state.csv"
},
"key": "State_Code",
"fields": ["Energy_Consumption", "Population", "State_Name"]
}
},
{
"calculate": "datum.Energy_Consumption / datum.Population",
"as": "Per_Capita_Consumption"
}
],
"projection": {
"type": "albers",
"rotate": [-137, 0],
"center": [0, -27.5],
"parallels": [-18, -36],
"scale": 800,
"translate": [310, 280]
},
"mark": "geoshape",
"encoding": {
"color": {
"field": "Per_Capita_Consumption",
"type": "quantitative",
"legend": {
"orient": "right",
"direction": "vertical",
"gradientLength": 500,
"title": "Per Capita Consumption (PJ)",
"titleFontSize": 12,
"labelFontSize": 10,
"titleLimit": 200
}
}
}
},
{
"data": {
"graticule": true
},
"mark": {
"type": "geoshape",
"stroke": "lightgray",
"strokeWidth": 0.5
},
"projection": {
"type": "albers",
"rotate": [-137, 0],
"center": [0, -27.5],
"parallels": [-18, -36],
"scale": 800,
"translate": [310, 280]
}
}
]
}
;
vegaEmbed('#vis', spec).catch(console.error);
</script>
</body>
</html>