Note that there are some explanatory texts on larger screens.

plurals
  1. POBounding csv data to topojson path - cloropleth
    text
    copied!<p>I am trying to bound some data to a topojson map. So far I've been able to draw the map of the US, with each path labeled by id: state name. What I'd like to do now is to bind data I have on an external csv to the map, to show each state of a hue based on the value in the csv (aka cloropleth). I've been looking for guides but I don't have the knowledge yet to understand the one on Mike Bostock's site, so I tried to bind the color with a function like so: </p> <pre><code>.attr("fill", "rgb(0, 0, " + Math.round(d.value * 255 / d3.max(d, function (d) {return d.value; })) + ")") </code></pre> <p>but it doesn't work. The page is here: <a href="http://www.dropbox.com/s/w2pe4omn895vt83/usa_malattie.html" rel="nofollow">http://www.dropbox.com/s/w2pe4omn895vt83/usa_malattie.html</a></p> <p>Commenting out the last part, with the csv load, gives the map with the tooltip showing, that also disappear when loading the csv data. Any help on how to resolve this would be highly appreciated, thanks in advance!</p> <p>EDIT: the csv looks like this:</p> <pre><code>id,value "Kentucky",207.4 "Mississippi",200.5 "West Virginia",196.6 "Louisiana",196.4 </code></pre> <p>the topojson like this:</p> <pre><code>{"type":"Topology","transform":{"scale": 0.011125945304891298,0.005248969801868182], "translate":[-178.21759836236586,18.92178634508703]}, "objects":{"usa":{"type":"GeometryCollection", "geometries":[{"type":"MultiPolygon","id":"Hawaii", "arcs":[[[0]],[[1]],[[2]],[[3]],[[4]],[[5]],[[6]]], "properties":{"STATE_NAME":"Hawaii"}}, </code></pre> <p>link for the csv: <a href="https://dl.dropboxusercontent.com/u/37967455/usa_malattie/usatopo.json" rel="nofollow">http://dl.dropboxusercontent.com/u/37967455/usa_malattie/death_parse.csv</a> link for the topojson: <a href="https://dl.dropboxusercontent.com/u/37967455/usa_malattie/usatopo.json" rel="nofollow">http://dl.dropboxusercontent.com/u/37967455/usa_malattie/usatopo.json</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload