Skip to content

Instantly share code, notes, and snippets.

View armollica's full-sized avatar

Andrew Mollica armollica

View GitHub Profile
@armollica
armollica / README.md
Last active May 31, 2016 02:11
Zoomable US States

Click a state to zoom and display counties. An extension of this block by Mike Bostock.

The color darker the greater the location quotient for employment in some industry (I forget what industry). The purpose of the example is to test out zoom functionality not to show data. That being said, the data is from the Bureau of Labor Statistics' QCEW survey.

@armollica
armollica / README.md
Last active November 25, 2015 03:16
HSL Grid

Mouse up and down to change the hue. Left and right to change the saturation and lightness.

@armollica
armollica / README.md
Last active December 5, 2015 13:22
Line Arrow

Drawing an arrowhead on a line in canvas. Move mouse to move line. Similar to a marker tag in SVG.

@armollica
armollica / README.md
Last active November 28, 2015 02:55
Arc Field
@armollica
armollica / README.md
Last active November 28, 2015 03:36
Circular Geography Selection

Click-hold to select geographic units whose centroids are within the circular area surrounding the cursor.

@armollica
armollica / README.md
Last active November 28, 2015 03:50
Triangular Tessellation

Tessellating equilateral triangles. Move mouse to adjust the size of the triangles. Click to invert the sizing.

Could be extended for two-dimensional binning, useful when there are a lot of data points. Other shapes that tesselate well are squares and hexagons.

@armollica
armollica / index.html
Last active January 6, 2018 13:19
Floating Particles
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
body {
background-color: black;
}
</style>
@armollica
armollica / README.md
Last active December 4, 2015 05:12
Shape Objects

Creating simple shape objects.

This can simplify drawing to canvas:

ellipse.context(canvas).stroke();

It also lets you encapsulates geometry-related helper functions. For example, the parametric function of an ellipse mapping to Cartesian coordinates:

var point = ellipse.cartesian(theta); // point = {x, y}
@armollica
armollica / README.md
Last active December 5, 2015 13:09
Neighboring Geography Selection

Testing out selecting neighboring geographic units. Uses TopoJSON's topojson.neighbors(objects) function.

Hover to highlight a county and it's neighboring counties. This lets you see how a county compares to its immediate neighbors for a given variable, here the 2014 unemployment rate.

Data sources: Unemployment data from U.S. Bureau of Labor Statistics. Shapefile from U.S. Census Bureau, cleaned up with QGIS, simplified with mapshaper.org. Color palette from ColorBrewer

@armollica
armollica / charts.js
Last active December 9, 2015 03:17
Fantasy Football Scores
var draw = {};
draw.own = function(selection, data, scale) {
var axis = selection.append("g").attr("class", "y axis")
.call(d3.svg.axis().scale(scale.y).orient("left"));
axis.selectAll("text")
.text(function(d) { return d == 1 ? "Week 1" : d});