# print out the version of IPython used import IPython IPython.version_info %%javascript // https://github.com/mbostock/d3/issues/1693 // loads d3 using require require.config({ paths: { d3: "http://d3js.org/d3.v3.min" } }); // example function on using d3 in callback require(["d3"], function(d3) { console.log(d3.version); }); %%javascript // https://github.com/mbostock/d3/issues/1693 require.config({ paths: { d3: "http://d3js.org/d3.v3.min", queue: "http://d3js.org/queue.v1.min", topojson: "http://d3js.org/topojson.v1.min" } }); require(["d3", "queue", "topojson"], function(d3, queue, topojson) { console.log(d3.version); console.log(queue.version); console.log(topojson.version); }); %%html %%html
%%javascript // https://github.com/mbostock/d3/issues/1693 require.config({ paths: { d3: "http://d3js.org/d3.v3.min", queue: "http://d3js.org/queue.v1.min", topojson: "http://d3js.org/topojson.v1.min" } }); require(["d3", "queue", "topojson"], function(d3, queue, topojson) { console.log(d3.version); console.log(queue.version); console.log(topojson.version); var width = 960, height = 500; var rateById = d3.map(); var quantize = d3.scale.quantize() .domain([0, .15]) .range(d3.range(9).map(function(i) { return "q" + i + "-9"; })); var path = d3.geo.path(); var svg = d3.select('#county_map').append("svg") .attr("width", width) .attr("height", height); queue() .defer(d3.json, "http://mashupguide.net/wwod14/us.json") .defer(d3.tsv, "http://mashupguide.net/wwod14/unemployment.tsv", function(d) { rateById.set(d.id, +d.rate); }) .await(ready); function ready(error, us) { svg.append("g") .attr("class", "counties") .selectAll("path") .data(topojson.feature(us, us.objects.counties).features) .enter().append("path") .attr("class", function(d) { return quantize(rateById.get(d.id)); }) .attr("d", path); svg.append("path") .datum(topojson.mesh(us, us.objects.states, function(a, b) { return a !== b; })) .attr("class", "states") .attr("d", path); } })