javascript - Replicating a chropleth in D3.js using d3.tsv -


i'm trying replicate mike bostock's chropleth using topojson file of mexican municipalties , coloring using .tsv matching id values polygons.

so far i've been able show map , polygons can't color based on values .tsv file.

enter image description here

i suspect problem in function i'm not entirely sure calling .tsv inside function

    queue()     .defer(d3.json, "mx5.topojson")     .defer(d3.tsv, "cosecha.tsv", function(d) { ratebyid.set(d.id, +d.rate); })     .await(ready);  function ready(error, mx5) {   svg.append("g")       .attr("class", "mx4")     .selectall("path")       .data(topojson.feature(mx5, mx5.objects.mx4).features)     .enter().append("path")       .attr("class", function(d) { return quantize(ratebyid.get(d.id)); })       .attr("d", path);   svg.append("path")       .datum(topojson.mesh(mx5, mx5.objects.estados, function(a, b) { return !== b; }))       .attr("class", "estados")       .attr("d", path);  } 

here link gist , here 1 topojson of mexican municipalities

any appreciated

your code expects counties indexed prop id, e.g. ratebyid.set(d.id, +d.rate).

however, tsv calls them "mun", in

"mun"   "rate" "01001" 350058.5 "01002" 224305 "01003" 132115 

so change d.id d.mun (in 2 places), or rename "mun"


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -