Commit 4f2616476f8f9c6bc7bdd0ae78fcd8768856a30a

Authored by lucvic
1 parent ab77b03a

Updated datasetexplorer-datalet

datalets/datasetexplorer-datalet/js/buildtreemap.js
... ... @@ -59,16 +59,6 @@ function build(root, place_holder) {
59 59 layout(root);
60 60 display(root);
61 61  
62   - function interpolate(min, max, value) {
63   - var colors = ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"];
64   - var ratio = value / (max - 1 - min) * Math.max(colors.length - 1, 1);
65   - var infI = Math.floor(ratio);
66   - var supI = Math.ceil(ratio);
67   - var subratio = supI == infI ? 0 : (ratio - infI) / (supI - infI);
68   - var color = d3.interpolateHsl( colors[infI], colors[supI] )( subratio );
69   - return color;
70   - }
71   -
72 62 function initialize(root) {
73 63 root.x = root.y = 0;
74 64 root.dx = width;
... ... @@ -82,7 +72,7 @@ function build(root, place_holder) {
82 72 // the children being overwritten when when layout is computed.
83 73 function accumulate(d) {
84 74 return (d._children = d.children)
85   - ? d.value = d.children.reduce(function(p, v) { return p + accumulate(v); }, 0)
  75 + ? d.value = d.children.reduce(function(p, v) { return p + accumulate(v); }, 5)
86 76 : d.value;
87 77 }
88 78  
... ... @@ -105,8 +95,9 @@ function build(root, place_holder) {
105 95 c.parent = d;
106 96 c.depth = d.depth + 1;
107 97 c.color = c.depth < 2
108   - ? interpolate(0, d._children.length, i++)
109   - : d3.rgb(d.color).brighter(.5);
  98 + ? d3.scale.ordinal().domain(d3.range(d._children.length)).range(["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"])(i++)
  99 + //? interpolate(0, d._children.length, i++)
  100 + : d.color; //d3.rgb(d.color).brighter(.5);
110 101 layout(c);
111 102 });
112 103 }
... ... @@ -141,12 +132,14 @@ function build(root, place_holder) {
141 132 .attr("class", "parent")
142 133 .call(rect)
143 134 .append("title")
144   - .text(function(d) { return formatNumber(d.value); });
  135 + .text(function(d) { return d.name; /*formatNumber(d.value);*/ });
145 136  
146 137 g.append("text")
147 138 .attr("dy", ".75em")
148 139 .text(function(d) { return (d._children) ? d.name : ''; })
149   - .call(text);
  140 + //.style("font-size", function(d) { return Math.min(16, (d.dx - 8) / this.getComputedTextLength() * 16) + "px"; })
  141 + .call(text)
  142 + ;
150 143  
151 144 function transition(d) {
152 145 if (transitioning || !d) return;
... ... @@ -192,8 +185,6 @@ function build(root, place_holder) {
192 185 if (!d._children[0]._children) {
193 186 var dataurl = d._children[0].name;
194 187 var pageurl = dataurl.replace(/\/download\/.*/, '');
195   -console.log(dataurl);
196   -console.log(pageurl);
197 188 dataletContainer = svg
198 189 .append("foreignObject")
199 190 .attr("width", 480)
... ... @@ -206,11 +197,10 @@ console.log(pageurl);
206 197 return g;
207 198 }
208 199  
209   -
210   -
211 200 function text(text) {
212 201 text.attr("x", function(d) { return x(d.x) + 6; })
213   - .attr("y", function(d) { return y(d.y) + 6; });
  202 + .attr("y", function(d) { return y(d.y) + 6; })
  203 + ;
214 204 }
215 205  
216 206 function rect(rect) {
... ...