Commit 4f2616476f8f9c6bc7bdd0ae78fcd8768856a30a
1 parent
ab77b03a
Updated datasetexplorer-datalet
Showing
1 changed file
with
10 additions
and
20 deletions
datalets/datasetexplorer-datalet/js/buildtreemap.js
@@ -59,16 +59,6 @@ function build(root, place_holder) { | @@ -59,16 +59,6 @@ function build(root, place_holder) { | ||
59 | layout(root); | 59 | layout(root); |
60 | display(root); | 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 | function initialize(root) { | 62 | function initialize(root) { |
73 | root.x = root.y = 0; | 63 | root.x = root.y = 0; |
74 | root.dx = width; | 64 | root.dx = width; |
@@ -82,7 +72,7 @@ function build(root, place_holder) { | @@ -82,7 +72,7 @@ function build(root, place_holder) { | ||
82 | // the children being overwritten when when layout is computed. | 72 | // the children being overwritten when when layout is computed. |
83 | function accumulate(d) { | 73 | function accumulate(d) { |
84 | return (d._children = d.children) | 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 | : d.value; | 76 | : d.value; |
87 | } | 77 | } |
88 | 78 | ||
@@ -105,8 +95,9 @@ function build(root, place_holder) { | @@ -105,8 +95,9 @@ function build(root, place_holder) { | ||
105 | c.parent = d; | 95 | c.parent = d; |
106 | c.depth = d.depth + 1; | 96 | c.depth = d.depth + 1; |
107 | c.color = c.depth < 2 | 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 | layout(c); | 101 | layout(c); |
111 | }); | 102 | }); |
112 | } | 103 | } |
@@ -141,12 +132,14 @@ function build(root, place_holder) { | @@ -141,12 +132,14 @@ function build(root, place_holder) { | ||
141 | .attr("class", "parent") | 132 | .attr("class", "parent") |
142 | .call(rect) | 133 | .call(rect) |
143 | .append("title") | 134 | .append("title") |
144 | - .text(function(d) { return formatNumber(d.value); }); | 135 | + .text(function(d) { return d.name; /*formatNumber(d.value);*/ }); |
145 | 136 | ||
146 | g.append("text") | 137 | g.append("text") |
147 | .attr("dy", ".75em") | 138 | .attr("dy", ".75em") |
148 | .text(function(d) { return (d._children) ? d.name : ''; }) | 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 | function transition(d) { | 144 | function transition(d) { |
152 | if (transitioning || !d) return; | 145 | if (transitioning || !d) return; |
@@ -192,8 +185,6 @@ function build(root, place_holder) { | @@ -192,8 +185,6 @@ function build(root, place_holder) { | ||
192 | if (!d._children[0]._children) { | 185 | if (!d._children[0]._children) { |
193 | var dataurl = d._children[0].name; | 186 | var dataurl = d._children[0].name; |
194 | var pageurl = dataurl.replace(/\/download\/.*/, ''); | 187 | var pageurl = dataurl.replace(/\/download\/.*/, ''); |
195 | -console.log(dataurl); | ||
196 | -console.log(pageurl); | ||
197 | dataletContainer = svg | 188 | dataletContainer = svg |
198 | .append("foreignObject") | 189 | .append("foreignObject") |
199 | .attr("width", 480) | 190 | .attr("width", 480) |
@@ -206,11 +197,10 @@ console.log(pageurl); | @@ -206,11 +197,10 @@ console.log(pageurl); | ||
206 | return g; | 197 | return g; |
207 | } | 198 | } |
208 | 199 | ||
209 | - | ||
210 | - | ||
211 | function text(text) { | 200 | function text(text) { |
212 | text.attr("x", function(d) { return x(d.x) + 6; }) | 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 | function rect(rect) { | 206 | function rect(rect) { |