/
chord - Kopie.html
76 lines (59 loc) · 1.87 KB
/
chord - Kopie.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
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font: 30px sans-serif;
}
svg text {
fill: grey;
font-size: 30px;
}
svg .values text {
pointer-events: none;
stroke-width: 0.5px;
}
.groups:hover {
cursor: pointer;
font-weight: bold;
}
</style>
<body>
<script src="d3/d3.v4.min.js"></script>
<script src="d3/d3-scale.v1.0.6.min.js"></script>
<script src="d3/d3-scale-chromatic.v1.1.1.min.js"></script>
<script src="viz/viz.v1.1.0.min.js"></script>
<script>
d3.json("chord_data.json", function(data) {
var index;
var colormap = {};
var dictIndex = 0;
for (index = 0; index < data.length;++index) {
key = data[index][0];
if(!(key in colormap)){
colormap[data[index][0]] = dictIndex;
++dictIndex
}
}
for (var key in colormap) {
t = colormap[key]/dictIndex;
colormap[key] = d3.interpolateSpectral(t);
}
var ch = viz.ch().data(data)
.padding(.01)
.innerRadius(430)
.outerRadius(450)
.duration(1000)
.chordOpacity(0.3)
.labelPadding(.03)
.fill(function(d) {
return colormap[d];
});
var width = 1200,
height = 1100;
var svg = d3.select("body").append("svg").attr("height", height).attr("width", width);
svg.append("g").attr("transform", "translate(600,550)").call(ch);
// adjust height of frame in bl.ocks.org
d3.select(self.frameElement).style("height", height + "px").style("width", width + "px");
});
</script>
</body>