1

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:

.attr("fill", "rgb(0, 0, " + Math.round(d.value * 255 / d3.max(d, function (d) {return d.value; })) + ")")

but it doesn't work. The page is here: http://www.dropbox.com/s/w2pe4omn895vt83/usa_malattie.html

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!

EDIT: the csv looks like this:

id,value
"Kentucky",207.4
"Mississippi",200.5
"West Virginia",196.6
"Louisiana",196.4

the topojson like this:

{"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"}},

link for the csv: http://dl.dropboxusercontent.com/u/37967455/usa_malattie/death_parse.csv link for the topojson: http://dl.dropboxusercontent.com/u/37967455/usa_malattie/usatopo.json

tomtomtom
  • 1,502
  • 1
  • 18
  • 27

1 Answers1

1

You may try the following command:

topojson -o final.json -e death_parse.csv --id-property=id -p STATE_NAME,color=+value -- usatopo.json
Alex Filipovici
  • 31,789
  • 6
  • 54
  • 78
  • yeah I thought of merging the files in one topojson, but I wanted to learn how to load the csv, so it could be possible to have the same map and load different csvs if needed – tomtomtom Aug 27 '13 at 16:55