112 .style("height", function(d) { return y(d.y + d.dy) - y(d.y) + 'px'; }) |
112 .style("height", function(d) { return y(d.y + d.dy) - y(d.y) + 'px'; }) |
113 .style("left", function(d) { return x(d.x) + 'px'; }) |
113 .style("left", function(d) { return x(d.x) + 'px'; }) |
114 .style("top", function(d) { return y(d.y) + 'px'; }); |
114 .style("top", function(d) { return y(d.y) + 'px'; }); |
115 } |
115 } |
116 |
116 |
|
117 function hexadecimalToInteger(hexadecimal) { |
|
118 var integer = []; |
|
119 for(var i = 1; i < 7; i += 2) { |
|
120 integer.push(parseInt(hexadecimal.slice(i, i + 2), 16)); |
|
121 } |
|
122 return integer; |
|
123 } |
|
124 |
117 function display(d) { |
125 function display(d) { |
118 breadcrumbs |
126 breadcrumbs |
119 .datum(d.parent) |
127 .datum(d.parent) |
120 .html(name(d)) |
128 .html(name(d)) |
121 .on("click", transition); |
129 .on("click", transition); |
128 .data(d._children) |
136 .data(d._children) |
129 .enter() |
137 .enter() |
130 .append("div") |
138 .append("div") |
131 .attr("data-id", function(d) { return d.id; }); |
139 .attr("data-id", function(d) { return d.id; }); |
132 |
140 |
|
141 var dMin = Math.min.apply(null, d._children.map(function(d){ return d.count; })); |
|
142 var dMax = Math.max.apply(null, d._children.map(function(d){ return d.count; })); |
|
143 |
|
144 function shade(d) { |
|
145 var color = "#becfd4"; |
|
146 var aColor = hexadecimalToInteger(color); |
|
147 var solidColor = "#71848d"; |
|
148 var aSolidColor = hexadecimalToInteger(solidColor); |
|
149 var aFillColor = []; |
|
150 for(var i = 0; i < 3; i++) { |
|
151 aFillColor.push((d.count - dMin) * (aSolidColor[i] - aColor[i]) / (dMax - dMin) + aColor[i]); |
|
152 } |
|
153 return '#' + (aFillColor.map(i => parseInt(i).toString(16))).join(''); |
|
154 } |
|
155 |
133 node.attr("class", function(d) { return "node" + ( d.id === self.get('filter').get('language') ? " selected" : "" ); }) |
156 node.attr("class", function(d) { return "node" + ( d.id === self.get('filter').get('language') ? " selected" : "" ); }) |
134 .call(position) |
157 .call(position) |
|
158 .style("background-color", function(d) { return shade(d); }) |
135 .on("click", selectHandler); |
159 .on("click", selectHandler); |
136 |
160 |
137 node.filter(function(d) { return d._children; }) |
161 node.filter(function(d) { return d._children; }) |
138 .classed("children", true) |
162 .classed("children", true) |
139 .on("click", transition) |
163 .on("click", transition) |