Skip to content

Instantly share code, notes, and snippets.

View vigorousnorth's full-sized avatar

Christian MilNeil vigorousnorth

  • StreetsblogMASS
  • Portland, Maine and Boston, Mass.
  • X @c_milneil
View GitHub Profile
@vigorousnorth
vigorousnorth / d3weathermap.js
Last active August 29, 2015 13:57
D3 weather map
var temps = {};
// Define historic climate data
temps = {
'Bangor' :
{
thiswinter_low: -20, thiswinter_lowdate: 'Jan. 4',
record_low: -32, record_lowdate: 'Feb. 2, 1948', record_lowsince: 1925
@vigorousnorth
vigorousnorth / adaptive.js
Last active August 29, 2015 14:07
Adaptive D3 map and legend.
// Andr Aroo Cumb Frank Hancock Kenne Knox Linc Oxford Penob Pisca Sagada Somerse Waldo Washing York
var data = [99.6, 87.2, 97.8, 70.7, 80.7, 99.1, 98.0, 99.4, 94.5, 88.7, 46.1, 91.9, 79.8, 86.7, 88.5, 98.8 ];
function pair(array) {
return array.slice(1).map(function(b, i) {
return [array[i], b];
});
}
$(document).ready(function() {
@vigorousnorth
vigorousnorth / arcs.js
Last active March 22, 2019 02:49
Arc map with scaled arrowheads
var svg,
width = 900,
height = 700;
var projection = d3.geo.equirectangular()
.rotate([-10,0]).scale(height/5).translate([width / 2, height / 2]).clipExtent([[0,0.1*height],[width,height*0.85]]);
var path = d3.geo.path()
.projection(projection);
@vigorousnorth
vigorousnorth / index.html
Last active January 13, 2019 01:37
Labelled graticules
<!DOCTYPE html>
<meta charset="utf-8">
<!-- A refinement of http://bl.ocks.org/mbostock/3664049 with labeled graticules -->
<style>
.graticule {
fill: none;
stroke: #000;
@vigorousnorth
vigorousnorth / index.html
Last active May 21, 2016 19:26
D3 bar chart with custom SVG path icons
<!DOCTYPE html>
<meta charset="utf-8">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
<script src="windchart.js"></script>
<style>
body {
@vigorousnorth
vigorousnorth / index.html
Last active January 26, 2016 18:47
D3 animated scatterplot
<!DOCTYPE html>
<html class="ocks-org do-not-copy">
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="urbanizedpopulation.js"></script>
<style>
@vigorousnorth
vigorousnorth / index.html
Last active May 28, 2019 12:15
Pie chart with rotated wedge labels
<!DOCTYPE html>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var piecolors = d3.scale.category20c();
var w = 600,
h = 460,
@vigorousnorth
vigorousnorth / index.html
Last active March 16, 2016 14:50
Animated isometric tetrahedra
<!DOCTYPE html>
<meta charset="utf-8">
<body style="width: 100%">
<canvas width="960" height="500" style="margin-left: auto; margin-right: auto;"></canvas>
<script src="http://d3js.org/d3-timer.v0.3.min.js"></script>
<script src="http://d3js.org/d3-ease.v0.7.min.js"></script>
<script src="isometric.js"></script>
<script>
var canvas = document.querySelector("canvas"),
State suicide-firearm suicide-suffocation suicide-poisoning suicide-other homicide-firearm homicide-other police-firearm others
Wyoming 56.6 13.8 13.2 2.8 5.9 5.5 0.4 1.8
Idaho 54.9 14.6 14.3 3.3 6.2 4.5 1.0 1.2
Montana 54.2 14.4 13.9 2.6 6.4 5.9 0.9 1.7
West Virginia 51.2 11.9 8.9 2.2 14.4 8.5 1.0 1.9
Alaska 49.5 17.0 8.1 2.5 13.0 8.1 0.7 1.1
Vermont 49.3 17.9 15.3 4.6 5.5 4.8 0.7 1.9
North Dakota 49.1 23.2 10.1 5.2 5.4 5.0 2.0
Kentucky 48.7 13.1 8.6 2.4 17.2 8.0 0.6 1.4
Maine 46.9 18.7 16.3 5.9 5.4 4.5 1.0 1.3
State suicide-firearm suicide-suffocation suicide-poisoning suicide-other homicide-firearm homicide-other police-firearm others pct_with_firearms
Wyoming 56.6 13.8 13.2 2.8 5.9 5.5 0.4 1.8 66
Idaho 54.9 14.6 14.3 3.3 6.2 4.5 1 1.2 56
Montana 54.2 14.4 13.9 2.6 6.4 5.9 0.9 1.7 63
West Virginia 51.2 11.9 8.9 2.2 14.4 8.5 1 1.9 58
Alaska 49.5 17 8.1 2.5 13 8.1 0.7 1.1 60
Vermont 49.3 17.9 15.3 4.6 5.5 4.8 0.7 1.9 44
North Dakota 49.1 23.2 10.1 5.2 5.4 5 2 56
Kentucky 48.7 13.1 8.6 2.4 17.2 8 0.6 1.4 48
Maine 46.9 18.7 16.3 5.9 5.4 4.5 1 1.3 40