Skip to content

Instantly share code, notes, and snippets.

@martgnz
Last active July 16, 2018 00:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martgnz/ce8efee65a26e4677e5e5d3da2c8f1a7 to your computer and use it in GitHub Desktop.
Save martgnz/ce8efee65a26e4677e5e5d3da2c8f1a7 to your computer and use it in GitHub Desktop.
US States
border: none
license: mit
<!DOCTYPE html>
<meta charset="utf-8" />
<body>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="https://d3js.org/topojson.v1.min.js"></script>
<script src="https://unpkg.com/d3-geo-projection@0.2.16/d3.geo.projection.min.js"></script>
<script src="https://unpkg.com/rbush@1.4.3/rbush.js"></script>
<script src="https://unpkg.com/spamjs@1.1.0/spam.min.js"></script>
<script type='text/javascript'>
var width = 960;
var height = 500;
d3.json("us-states.json", function(error, d) {
topojson.presimplify(d);
var map = new StaticCanvasMap({
element: "body",
projection: d3.geo
.albersUsa()
.scale(1000)
.translate([width / 2, height / 2]),
data: [
{
features: topojson.feature(d, d.objects["states"]),
static: {
paintfeature: function(parameters, d) {
parameters.context.lineWidth = 1;
parameters.context.strokeStyle = "rgb(255,255,255)";
parameters.context.fillStyle = "rgb(30, 30, 30)";
parameters.context.stroke();
parameters.context.fill();
}
}
}
]
});
map.init();
});
</script>
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sergeiwallace
Copy link

sergeiwallace commented Jul 16, 2018

Why isn't the US-atlas dataset drawn correctly by Spam?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment