Skip to content

Instantly share code, notes, and snippets.

Last active Oct 28, 2019
What would you like to do?
Plant Hardiness Zones
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
body {
position: relative;
.key {
font: 10px sans-serif;
position: absolute;
top: 0;
left: 0;
.caption {
font-weight: bold;
.key path {
display: none;
.key line {
stroke: #000;
shape-rendering: crispEdges;
<script src="//"></script>
<script src="//"></script>
var width = 960,
height = 500;
var color = d3.scale.linear()
.domain([-35, 0, 35])
.range(["#4575b4", "#ffffbf", "#a50026"])
var x = d3.scale.linear()
.domain([-40, 40])
.range([0, 240]);
var xAxis = d3.svg.axis()
var canvas ="body").append("canvas")
.attr("width", width)
.attr("height", height);
var context = canvas.node().getContext("2d");
var path = d3.geo.path()
var svg ="body").append("svg")
.attr("width", width)
.attr("height", height)
.attr("class", "key")
.attr("transform", "translate(60," + (height - 60) + ")");
.attr("height", 8)
.attr("x", function(d) { return x(d[0]); })
.attr("width", function(d) { return x(d[1]) - x(d[0]); })
.style("fill", function(d) { return color(d[0]); });"text")
.attr("class", "caption")
.attr("y", -6)
.text("Avg. annual extreme minimum temperature, °F");
d3.json("ophz.json", function(error, ophz) {
if (error) throw error;
topojson.feature(ophz, ophz.objects.b)
.sort(function(a, b) { return a.t - b.t; })
function pair(array) {
return array.slice(1).map(function(b, i) {
return [array[i], b];
function render(d) {
var t =;
if (t <= -98) return;
context.fillStyle = color(t);
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Copy link

nayfin commented Nov 14, 2015

I'm rookie here. I want to use this for a companion gardening website I'm developing. I want to allow users to select their hardiness zones by simply clicking their location on the map by following this tutorial:
I can't even get the image to show up. The problem seems to be that I can't get access to the two scripts tagged after the style. I tried changing them in my code to reference the URL directly, then tried copy pasting their contained JS to a new file. No dice either time . I'm new to github and have been programming with JS for about 6 months. Any help you can offer on using this image would be appreciated, even if it's just a link to a forum that I should have already found. Thanks for your work on the image. It looks awesome hope I can use it soon.

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