Sha256: 506c677d0cfdf680fbfb2376b20fb4c6be975c615feef509d39e69ab786c4902

Contents?: true

Size: 863 Bytes

Versions: 6

Compression:

Stored size: 863 Bytes

Contents

var data; // loaded asynchronously

var path = d3.geo.path();

var svg = d3.select("#chart")
  .append("svg:svg");

var counties = svg.append("svg:g")
    .attr("id", "counties")
    .attr("class", "Blues");

var states = svg.append("svg:g")
    .attr("id", "states");

d3.json("../data/us-counties.json", function(json) {
  counties.selectAll("path")
      .data(json.features)
    .enter().append("svg:path")
      .attr("class", data ? quantize : null)
      .attr("d", path);
});

d3.json("../data/us-states.json", function(json) {
  states.selectAll("path")
      .data(json.features)
    .enter().append("svg:path")
      .attr("d", path);
});

d3.json("unemployment.json", function(json) {
  data = json;
  counties.selectAll("path")
      .attr("class", quantize);
});

function quantize(d) {
  return "q" + Math.min(8, ~~(data[d.id] * 9 / 12)) + "-9";
}

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
bum-0.0.17 public/d3/examples/choropleth/choropleth.js
bum-0.0.16 public/d3/examples/choropleth/choropleth.js
bum-0.0.15 public/d3/examples/choropleth/choropleth.js
bum-0.0.14 public/d3/examples/choropleth/choropleth.js
bum-0.0.13 public/d3/examples/choropleth/choropleth.js
bum-0.0.12 public/d3/examples/choropleth/choropleth.js