forked from Charlynux/d3js-presentation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (29 loc) · 901 Bytes
/
app.js
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
d3.json("datas/followers.json", (err, data) => render(data));
function render(data) {
var width = 500;
var height = 500;
var svg = d3.select('.container')
.append('svg')
.attr({
width: width,
height: height
});
var pack = d3.layout.pack()
.size([width, height])
.value(d => d.followersCount)
.children(d => d.followers)
.sort(null)
.padding(1.5);
var nodes = svg.selectAll(".follower")
.data(pack.nodes(data))
.enter()
.append("g").attr("class", "follower")
.attr("transform", d => "translate("+ d.x + ", " + d.y + ")");
nodes.append("title")
.text(d => d.screenName)
nodes.append("circle").attr({
r: d => d.r,
fill: d => d.parent ? "#" + d.profileBackgroundColor : "none"
})
.on("click", d => console.log(d.screenName));
}