-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
207 lines (194 loc) · 7.97 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
<!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>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"
integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL"
crossorigin="anonymous"></script>
<!-- CSS file -->
<link rel="stylesheet" type="text/css" href="css/styles.css" media="all">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<style>
body {
background-image: url('image/img.png');
background-size: cover; /* 可以使用 'contain' 以保持图像比例 */
}
</style>
</head>
<body>
<div class="main text-center">
<h2>Mental Health Disorders and Depression Data Statistics</h2>
<div class="row" >
<div class="col">
</div>
<div class="col-8" id="choropleth_map">
</div>
<div class="col">
</div>
</div>
<div class="row">
<div class="col">
</div>
<div class="col-8" id="choropleth_map2">
</div>
<div class="col">
</div>
</div>
</div>
<script type="text/javascript">
var spec = {
"$schema": "https://vega.github.io/schema/vega-lite/v5.json",
"data": {
"url":"https://raw.githubusercontent.com/FIT3179/Vega-Lite/main/6_advanced_examples/data/earthquake_lite.csv"
},
"vconcat": [
{
"width": "container",
"height": 400,
"title": "Earthquakes above a magnitude of 5 (2000-2021)",
"projection": {"type": "equalEarth", "rotate": [-150, 0,0]},
"layer": [
{
"data": {
"url":"https://raw.githubusercontent.com/FIT3179/Vega-Lite/main/2_symbol_map/js/ne_110m_admin_0_countries.topojson",
"format": {
"type": "topojson",
"feature": "ne_110m_admin_0_countries"
}
},
"mark": {"type": "geoshape", "fill": "lightgray","stroke": "white"}
},
{
"data": {
"url":"https://raw.githubusercontent.com/FIT3179/Vega-Lite/main/7_others/oceans.topojson",
"format": {"type": "topojson", "feature": "oceans"}
},
"mark": {"type": "geoshape", "fill": "skyblue"}
},
{
"data": {
"url":"https://raw.githubusercontent.com/FIT3179/Vega-Lite/main/2_symbol_map/js/WorldMapWithGraticules.topojson",
"format": {"type": "topojson", "feature": "ne_110m_graticules_30"}
},
"mark": {"type": "geoshape", "fill": null, "stroke": "lightgray"}
},
{
"transform": [{"filter": {"param": "time_brush"}}],
"encoding": {
"longitude": {"field": "longitude", "type":"quantitative"},
"latitude": {"field": "latitude", "type":"quantitative"},
"color": {
"field": "mag",
"type": "quantitative",
"title": "Magnitude",
"scale": {
"type": "threshold",
"domain": [5.5, 6, 6.5, 7],
"range": ["#fdbe85", "#fd8d3c", "#e6550d","#bd0026", "#7f0000"]
}
},
"tooltip": [
{"field": "time", "type": "temporal"},
{"field": "mag", "type": "quantitative"},
{"field": "place", "type": "nominal"}
]
},
"layer": [
{"mark": {"type": "circle", "opacity": 0.4, "size": 15}},
{
"transform": [
{
"window": [{"op": "rank", "as": "ranking"}],
"sort": [{"field": "mag", "order": "descending"}]
},
{"filter": "datum.ranking == 1"},
{
"calculate": "'The worst earthquake of; the selected period: ' + datum['mag']",
"as": "text_annotation_raw"
},
{
"calculate": "split(datum.text_annotation_raw, ';')",
"as": "text_annotation"
}
],
"mark": {
"type": "text",
"align": "right",
"dx": -8,
"dy": -8,
"baseline": "middle",
"fontStyle": "italic"
},
"encoding": {"text": {"field": "text_annotation"}}
}
]
}
]
},
{
"width": "container",
"height": 60,
"mark": "line",
"title": "Use this line chart to filter out the data based on time",
"params": [
{
"name": "time_brush",
"select": {"type": "interval", "encodings": ["x"]}
}
],
"encoding": {
"x": {
"field": "time",
"timeUnit": "yearmonth",
"axis": {"title": "", "format": "%Y"}
},
"y": {
"aggregate": "count",
"axis": {"tickCount": 3, "grid": false},
"title": "Count"
}
}
},
{
"width": "container",
"transform": [
{
"bin": {"step": 0.5, "extent": [5, 7]},
"field": "mag",
"as": "magnitude"
}
],
"mark": "area",
"encoding": {
"x": {
"field": "time",
"timeUnit": "yearmonth",
"scale": {"domain": {"param": "time_brush"}},
"axis": {"title": "", "tickCount": 5, "grid": false}
},
"y": {"aggregate": "count", "title": "Count of Earthquakes"},
"color": {
"field": "magnitude",
"scale": {
"range": ["#fdbe85", "#fd8d3c", "#e6550d", "#bd0026", "#7f0000"]
},
"legend": null
}
}
}
],
"config": {"title": {"font": "sans-serif", "fontSize": 14}}
}
;
// Embed the updated spec into the #choropleth_map element
vegaEmbed('#choropleth_map', spec).then(function (result) {
}).catch(console.error);
// Embed the updated spec into the #choropleth_map element
vegaEmbed('#choropleth_map2', spec).then(function (result) {
}).catch(console.error);
</script>
</body>
</html>