-
-
Save caged/5967514 to your computer and use it in GitHub Desktop.
Revisions
-
Justin Palmer revised this gist
Jul 10, 2013 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,8 @@ svg.selectAll("path") .data(topojson.feature(topology, topology.objects.counties).features) .enter().append("path") .attr("d", path) .on('click', function() { console.log(arguments) }); }); </script> -
mbostock revised this gist
May 13, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ </style> <body> <script src="http://d3js.org/d3.v3.min.js"></script> <script src="http://d3js.org/topojson.v1.min.js"></script> <script> var width = 960, @@ -29,7 +29,7 @@ d3.json("/mbostock/raw/4090846/us.json", function(error, topology) { svg.selectAll("path") .data(topojson.feature(topology, topology.objects.counties).features) .enter().append("path") .attr("d", path); }); -
mbostock revised this gist
Feb 18, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,7 +27,7 @@ .attr("width", width) .attr("height", height); d3.json("/mbostock/raw/4090846/us.json", function(error, topology) { svg.selectAll("path") .data(topojson.object(topology, topology.objects.counties).geometries) .enter().append("path") -
mbostock revised this gist
Nov 23, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
mbostock revised this gist
Nov 23, 2012 . 2 changed files with 1 addition and 64 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -15,7 +15,7 @@ </style> <body> <script src="http://d3js.org/d3.v3.min.js"></script> <script src="http://d3js.org/topojson.v0.min.js"></script> <script> var width = 960, This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,63 +0,0 @@ -
mbostock revised this gist
Nov 23, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ A demo of [TopoJSON](https://github.com/mbostock/topojson) on a U.S. counties shapefile from the U.S. census bureau. The same TopoJSON file can also be used to show [states](../4090848). -
mbostock revised this gist
Nov 23, 2012 . 1 changed file with 7 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,12 +2,16 @@ <meta charset="utf-8"> <style> path { fill: #ccc; stroke: #fff; stroke-width: .5px; } path:hover { fill: red; } </style> <body> <script src="http://d3js.org/d3.v3.min.js"></script> @@ -17,8 +21,6 @@ var width = 960, height = 500; var path = d3.geo.path(); var svg = d3.select("body").append("svg") @@ -29,13 +31,6 @@ svg.selectAll("path") .data(topojson.object(topology, topology.objects.counties).geometries) .enter().append("path") .attr("d", path); }); -
mbostock revised this gist
Nov 23, 2012 . 2 changed files with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1 @@ A demo of [TopoJSON](https://github.com/mbostock/topojson) on a U.S. counties shapefile from the U.S. census bureau. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,9 +25,9 @@ .attr("width", width) .attr("height", height); d3.json("../4090846/us.json", function(error, topology) { svg.selectAll("path") .data(topojson.object(topology, topology.objects.counties).geometries) .enter().append("path") .attr("d", path) .style("fill", function(d) { return color(d.id / 1000 | 0); }) -
mbostock revised this gist
Nov 21, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,7 @@ .enter().append("path") .attr("d", path) .style("fill", function(d) { return color(d.id / 1000 | 0); }) .style("fill-opacity", function(d) { return ((d.id % 6) + 6) / 12; }); svg.append("path") .datum(topojson.mesh(topology)) -
mbostock revised this gist
Nov 21, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,7 +30,7 @@ .data(topojson.object(topology, topology.objects[0]).geometries) .enter().append("path") .attr("d", path) .style("fill", function(d) { return color(d.id / 1000 | 0); }) .style("fill-opacity", function(d) { return ((d.id % 10) + 2) / 12; }); svg.append("path") -
mbostock revised this gist
Nov 21, 2012 . 1 changed file with 3 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,10 +17,7 @@ var width = 960, height = 500; var color = d3.scale.category20c(); var path = d3.geo.path(); @@ -33,7 +30,8 @@ .data(topojson.object(topology, topology.objects[0]).geometries) .enter().append("path") .attr("d", path) .style("fill", function(d) { return color(d.id % 1000); }) .style("fill-opacity", function(d) { return ((d.id % 10) + 2) / 12; }); svg.append("path") .datum(topojson.mesh(topology)) -
mbostock revised this gist
Nov 21, 2012 . 1 changed file with 8 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -17,8 +17,12 @@ var width = 960, height = 500; var color = d3.scale.linear() .domain([0, 30000, 60000]) .range(["steelblue", "orange", "brown"]) .interpolate(d3.interpolateHcl); var path = d3.geo.path(); var svg = d3.select("body").append("svg") .attr("width", width) @@ -29,12 +33,12 @@ .data(topojson.object(topology, topology.objects[0]).geometries) .enter().append("path") .attr("d", path) .style("fill", function(d) { return color(d.id); }); svg.append("path") .datum(topojson.mesh(topology)) .attr("class", "stroke") .attr("d", path); }); </script> -
mbostock revised this gist
Nov 21, 2012 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,9 +25,9 @@ .attr("height", height); d3.json("../4090846/us-counties.json", function(error, topology) { svg.selectAll("path") .data(topojson.object(topology, topology.objects[0]).geometries) .enter().append("path") .attr("d", path) .style("fill", function(d) { return "#" + formatId(d.id); }); -
mbostock revised this gist
Nov 21, 2012 . 1 changed file with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,10 +2,6 @@ <meta charset="utf-8"> <style> .stroke { fill: none; stroke: #000; @@ -21,7 +17,8 @@ var width = 960, height = 500; var formatId = d3.format("06d"), path = d3.geo.path(); var svg = d3.select("body").append("svg") .attr("width", width) @@ -31,7 +28,8 @@ svg.append("path") .datum(topojson.object(topology, topology.objects[0])) .attr("class", "fill") .attr("d", path) .style("fill", function(d) { return "#" + formatId(d.id); }); svg.append("path") .datum(topojson.mesh(topology)) -
mbostock revised this gist
Nov 21, 2012 . 1 changed file with 12 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,9 +2,14 @@ <meta charset="utf-8"> <style> .fill { fill: #ccc; } .stroke { fill: none; stroke: #000; stroke-width: .5px; } </style> @@ -23,8 +28,14 @@ .attr("height", height); d3.json("../4090846/us-counties.json", function(error, topology) { svg.append("path") .datum(topojson.object(topology, topology.objects[0])) .attr("class", "fill") .attr("d", path); svg.append("path") .datum(topojson.mesh(topology)) .attr("class", "stroke") .attr("d", path); }); -
mbostock revised this gist
Nov 21, 2012 . 2 changed files with 62 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1 @@ A demo of [TopoJSON](https://github.com/mbostock/topojson) on a U.S. counties shapefile from the U.S. census bureau. The original GeoJSON file was 2.2M; the TopoJSON file is 660K, a reduction of 70.5%! (Or gzipped, a 71% reduction from 596K to 176K.) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,23 +1,63 @@ topojson = (function() { function mesh(topology) { var arcs = [], i = -1, n = topology.arcs.length; while (++i < n) arcs.push([i]); return object(topology, {type: "MultiLineString", arcs: arcs}); } function object(topology, o) { var tf = topology.transform, kx = tf.scale[0], ky = tf.scale[1], dx = tf.translate[0], dy = tf.translate[1], arcs = topology.arcs; function arc(i, points) { if (points.length) points.pop(); for (var a = arcs[i < 0 ? ~i : i], k = 0, n = a.length, x = 0, y = 0, p; k < n; ++k) points.push([ (x += (p = a[k])[0]) * kx + dx, (y += p[1]) * ky + dy ]); if (i < 0) reverse(points, n); } function line(arcs) { var points = []; for (var i = 0, n = arcs.length; i < n; ++i) arc(arcs[i], points); return points; } function polygon(arcs) { return arcs.map(line); } function geometry(o) { o = Object.create(o); o.coordinates = geometryType[o.type](o.arcs); return o; } var geometryType = { LineString: line, MultiLineString: polygon, Polygon: polygon, MultiPolygon: function(arcs) { return arcs.map(polygon); } }; return o.type === "GeometryCollection" ? (o = Object.create(o), o.geometries = o.geometries.map(geometry), o) : geometry(o); } function reverse(array, n) { var t, j = array.length, i = j - n; while (i < --j) t = array[i], array[i++] = array[j], array[j] = t; } return { version: "0.0.2", mesh: mesh, object: object }; })(); -
mbostock revised this gist
Nov 17, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,3 @@ A demo of [TopoJSON](https://github.com/mbostock/topojson) on a U.S. counties shapefile from the U.S. census bureau. The original GeoJSON file was 2.2M; the TopoJSON mesh is 436K, a reduction of 80.4%! (Or gzipped, a 80.1% reduction from 596K to 120K.) TopoJSON is a work in progress. Currently, it can produce a mesh but not yet reconstruct the source geometries. That capability will be coming shortly. -
mbostock revised this gist
Nov 17, 2012 . 1 changed file with 9 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,13 +3,19 @@ var topojson = { mesh: function(topology) { var kx = topology.transform.scale[0], ky = topology.transform.scale[1], dx = topology.transform.translate[0], dy = topology.transform.translate[1]; return { type: "MultiLineString", coordinates: topology.arcs.map(function(arc) { var y0 = 0, x0 = 0; return arc.map(function(point) { var x1 = x0 + point[0], y1 = y0 + point[1]; x0 = x1; y0 = y1; return [x1 * kx + dx, y1 * ky + dy]; }); }) }; -
mbostock revised this gist
Nov 17, 2012 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,8 +7,8 @@ var topojson = { y0 = topology.transform.translate[1]; return { type: "MultiLineString", coordinates: topology.arcs.map(function(arc) { return arc.map(function(point) { return [point[0] * kx + x0, point[1] * ky + y0]; }); }) -
mbostock revised this gist
Nov 17, 2012 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
mbostock revised this gist
Nov 16, 2012 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,3 @@ A demo of [TopoJSON](https://github.com/mbostock/topojson) on a U.S. counties shapefile from the U.S. census bureau. The original GeoJSON file was 2.2M; the TopoJSON mesh is 628K, a reduction of 72%! (Or gzipped, a 70% reduction from 596K to 176K.) TopoJSON is a work in progress. Currently, it can produce a mesh but not yet reconstruct the source geometries. That capability will be coming shortly. -
mbostock revised this gist
Nov 16, 2012 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ A demo of [TopoJSON](https://github.com/mbostock/topojson) on a U.S. counties shapefile from the U.S. census bureau. The original GeoJSON file was 2.2M; the TopoJSON mesh is 628K. TopoJSON is still a work in progress. Currently, it can produce a mesh but not yet reconstruct the source geometries. That capability will be coming shortly. -
mbostock revised this gist
Nov 16, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ .attr("width", width) .attr("height", height); d3.json("../4090846/us-counties.json", function(error, topology) { svg.append("path") .datum(topojson.mesh(topology)) .attr("d", path); -
mbostock revised this gist
Nov 16, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,7 +22,7 @@ .attr("width", width) .attr("height", height); d3.json("../4090846/us-states.json", function(error, topology) { svg.append("path") .datum(topojson.mesh(topology)) .attr("d", path); -
mbostock created this gist
Nov 16, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ <!DOCTYPE html> <meta charset="utf-8"> <style> path { fill: none; stroke: #000; } </style> <body> <script src="http://d3js.org/d3.v3.min.js"></script> <script src="topojson.js"></script> <script> var width = 960, height = 500; var path = d3.geo.path(); var svg = d3.select("body").append("svg") .attr("width", width) .attr("height", height); d3.json("../4090846/us-state-boundaries.json", function(error, topology) { svg.append("path") .datum(topojson.mesh(topology)) .attr("d", path); }); </script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ var topojson = { version: "0.0.1", mesh: function(topology) { var kx = topology.transform.scale[0], ky = topology.transform.scale[1], x0 = topology.transform.translate[0], y0 = topology.transform.translate[1]; return { type: "MultiLineString", coordinates: topology.coordinates.map(function(lineString) { return lineString.map(function(point) { return [point[0] * kx + x0, point[1] * ky + y0]; }); }) }; } };