-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
52 lines (43 loc) · 1.18 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
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.canton-BPK { fill: #ddc; }
.canton-HNK { fill: #cdd; }
.canton-K10 { fill: #cdc; }
.canton-KS { fill: #dcd; }
.canton-PK { fill: #ddc; }
.canton-SBK { fill: #cdd; }
.canton-TK { fill: #cdc; }
.canton-USK { fill: #dcd; }
.canton-ZDK { fill: #cdc; }
.canton-ZHK { fill: #dcd; }
</style>
<body>
<script src="http://d3js.org/d3.v3.js"></script>
<script src="http://d3js.org/topojson.v1.js"></script>
<script>
var width = 960,
height = 800;
// height = 1160;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("geodata/cantons.json", function(error, fbih) {
console.log(fbih);
var cantons = topojson.feature(fbih, fbih.objects.cantons);
console.log(cantons);
// define projection
var projection = d3.geo.mercator()
.center([18, 43])
.scale(6000)
.translate([width / 2, height / 2]);
// path definition
var path = d3.geo.path()
.projection(projection);
svg.selectAll(".canton")
.data(cantons.features)
.enter().append("path")
.attr("class", function(d) { console.log(d); return "canton-" + d.id; })
.attr("d", path);
});
</script>