source: Dev/trunk/d3/examples/choropleth/choropleth.js @ 76

Last change on this file since 76 was 76, checked in by fpvanagthoven, 14 years ago

d3

File size: 863 bytes
Line 
1var data; // loaded asynchronously
2
3var path = d3.geo.path();
4
5var svg = d3.select("#chart")
6  .append("svg:svg");
7
8var counties = svg.append("svg:g")
9    .attr("id", "counties")
10    .attr("class", "Blues");
11
12var states = svg.append("svg:g")
13    .attr("id", "states");
14
15d3.json("../data/us-counties.json", function(json) {
16  counties.selectAll("path")
17      .data(json.features)
18    .enter().append("svg:path")
19      .attr("class", data ? quantize : null)
20      .attr("d", path);
21});
22
23d3.json("../data/us-states.json", function(json) {
24  states.selectAll("path")
25      .data(json.features)
26    .enter().append("svg:path")
27      .attr("d", path);
28});
29
30d3.json("unemployment.json", function(json) {
31  data = json;
32  counties.selectAll("path")
33      .attr("class", quantize);
34});
35
36function quantize(d) {
37  return "q" + Math.min(8, ~~(data[d.id] * 9 / 12)) + "-9";
38}
Note: See TracBrowser for help on using the repository browser.