An example of the Chrome performance regression handling complex SVGs
-
-
Save oller/da646d7f4c8e78f5c229a9e4001ec415 to your computer and use it in GitHub Desktop.
Chrome SVG Performance Regression
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 characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.zip { | |
fill: white; | |
stroke: #CCC; | |
stroke-width: .5px; | |
cursor: pointer; | |
} | |
.zip:hover { | |
fill: red; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script src="http://d3js.org/queue.v1.min.js"></script> | |
<script src="http://d3js.org/topojson.v1.min.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); | |
queue() | |
.defer(d3.json, "zips_us_topo.json") | |
.await(ready); | |
function ready(error, us) { | |
svg.append("g") | |
.attr("class", "counties") | |
.selectAll("path") | |
.data(topojson.feature(us, us.objects.zip_codes_for_the_usa).features) | |
.enter().append("path") | |
.attr("class", "zip") | |
.attr("data-zip", function(d) {return d.properties.zip; }) | |
.attr("data-state", function(d) {return d.properties.state; }) | |
.attr("data-name", function(d) {return d.properties.name; }) | |
.attr("d", path); | |
} | |
</script> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment