-
Notifications
You must be signed in to change notification settings - Fork 2
/
hk_map_background.html
39 lines (37 loc) · 1.61 KB
/
hk_map_background.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
<!DOCTYPE html>
<html>
<head>
<style>
.vega-actions a {
margin-right: 12px;
color: #757575;
font-weight: normal;
font-size: 13px;
}
.error {
color: red;
}
</style>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm//vega@4"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm//vega-lite@2.6.0"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm//vega-embed@3"></script>
</head>
<body>
<div id="vis"></div>
<script>
var spec = {"config": {"view": {"width": 400, "height": 300}}, "data": {"url": "https://raw.githubusercontent.com/ywng/d3-js-map-hong-kong/master/HKG_adm.json", "format": {"feature": "HKG_adm1_1", "type": "topojson"}}, "mark": {"type": "geoshape", "fill": "lightgray", "stroke": "white"}, "height": 300, "projection": {"type": "mercator"}, "title": "Hong Kong Hospitals", "width": 500, "$schema": "https://vega.github.io/schema/vega-lite/v2.6.0.json"};
var embedOpt = {"mode": "vega-lite"};
function showError(el, error){
el.innerHTML = ('<div class="error" style="color:red;">'
+ '<p>JavaScript Error: ' + error.message + '</p>'
+ "<p>This usually means there's a typo in your chart specification. "
+ "See the javascript console for the full traceback.</p>"
+ '</div>');
throw error;
}
const el = document.getElementById('vis');
vegaEmbed("#vis", spec, embedOpt)
.catch(error => showError(el, error));
</script>
</body>
</html>