46 .style("width", function(d) { return Math.max(10 + d.r, d.r) * 2 + 'px'; }) |
46 .style("width", function(d) { return Math.max(10 + d.r, d.r) * 2 + 'px'; }) |
47 .style("height", function(d) { return Math.max(10 + d.r, d.r) * 2 + 'px'; }) |
47 .style("height", function(d) { return Math.max(10 + d.r, d.r) * 2 + 'px'; }) |
48 .style("position", "absolute") |
48 .style("position", "absolute") |
49 .style("left", function(d) { return d.x - Math.max(10 + d.r, d.r) + 'px'; }) |
49 .style("left", function(d) { return d.x - Math.max(10 + d.r, d.r) + 'px'; }) |
50 .style("top", function(d) { return d.y - Math.max(10 + d.r, d.r) + 'px'; }) |
50 .style("top", function(d) { return d.y - Math.max(10 + d.r, d.r) + 'px'; }) |
51 .on('click', function(d) { self.get('setQueryParameters')(d.name); }); |
51 .on('click', function(d) { self.get('setQueryParameters')(d.id); }); |
52 |
52 |
53 item.append("span") |
53 item.append("span") |
54 .text(function(d) { return d.name; }) |
54 .text(function(d) { return d.name; }) |
55 .style("text-align", "center") |
55 .style("text-align", "center") |
56 .style("display", function(d) { return d.children ? 'none' : 'inline-block'; }) |
56 .style("display", function(d) { return d.children ? 'none' : 'inline-block'; }) |
71 svg_nodes.enter().append("g") |
71 svg_nodes.enter().append("g") |
72 .attr("class", function(d) { return "node" + (!d.children ? " leaf" : ""); }) |
72 .attr("class", function(d) { return "node" + (!d.children ? " leaf" : ""); }) |
73 .attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; }); |
73 .attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; }); |
74 |
74 |
75 var leaf = svg.selectAll(".leaf") |
75 var leaf = svg.selectAll(".leaf") |
76 .on('click', function(d) { self.get('setQueryParameters')(d.name); }); |
76 .on('click', function(d) { self.get('setQueryParameters')(d.id); }); |
77 |
77 |
78 leaf.append("circle") |
78 leaf.append("circle") |
79 .attr("r", function(d) { return Math.max(7.5 + d.r * 2, d.r * 2); }) |
79 .attr("r", function(d) { return Math.max(7.5 + d.r * 2, d.r * 2); }) |
80 .attr("fill", function(d) { return d.fill; }) |
80 .attr("fill", function(d) { return d.fill; }) |
81 .attr("stroke", function() { return "#000"; }); |
81 .attr("stroke", function() { return "#000"; }); |
91 var nodes = {}; |
91 var nodes = {}; |
92 var children = {}; |
92 var children = {}; |
93 |
93 |
94 Object.keys(json).forEach(function(key) { |
94 Object.keys(json).forEach(function(key) { |
95 var discourse = json[key]; |
95 var discourse = json[key]; |
96 var index = self.get('constants').DISCOURSES[key]; |
96 var category_key = self.get('constants').DISCOURSE_CATEGORY_KEYS[key]; |
97 var category = self.get('constants').DISCOURSE_CATEGORIES[index]; |
97 var category_value = self.get('constants').DISCOURSE_CATEGORY_VALUES[category_key]; |
98 |
98 |
99 children[index] = children[index] || {}; |
99 children[category_key] = children[category_key] || {}; |
100 children[index]['name'] = index; |
100 children[category_key]['name'] = category_key; |
101 children[index]['children'] = children[index]['children'] || []; |
101 children[category_key]['children'] = children[category_key]['children'] || []; |
102 children[index]['children'].push({ "name": discourse.label, "value": discourse.count, "fill": category.fill }); |
102 children[category_key]['children'].push({ "id": key, "name": discourse.label, "value": discourse.count, "fill": category_value.fill }); |
103 }); |
103 }); |
104 |
104 |
105 nodes.children = []; |
105 nodes.children = []; |
106 Object.keys(children).forEach(function(key) { |
106 Object.keys(children).forEach(function(key) { |
107 nodes.children.push(children[key]); |
107 nodes.children.push(children[key]); |