[ Launch: bars ] 9820337 by milroc
d3.custom = {}; | |
d3.custom.utils = {}; | |
d3.custom.utils.windowResize = function() {}; | |
d3.custom.heatmap = function() { | |
// basic data | |
var margin = {top: 0, bottom: 0, left: 0, right: 0}, |
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<html> | |
<head> | |
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'> | |
<style> | |
.axis text { | |
font: 14px 'Inconsolata'; | |
} |
{ | |
"name": "flare", | |
"children": [ | |
{ | |
"name": "analytics", | |
"children": [ | |
{ | |
"name": "cluster", | |
"children": [ | |
{"name": "AgglomerativeCluster", "size": 3938}, |
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<html> | |
<head> | |
<!-- CDN IMPORTS --> | |
<link href='http://fonts.googleapis.com/css?family=Inconsolata' rel='stylesheet' type='text/css'> | |
<!-- LOCAL IMPORTS --> | |
<!-- IN GIST --> | |
<link rel="stylesheet/less" type="text/css" href="style.less"> |
d3.legend is a quick hack to add a legend to a d3
chart. Simply add a g
and .call(d3.legend)
. Any elements that have a title set in the "data-legend"
attribute will be included when d3.legend
is called. Each title will appear only once (even when multiple items define the same data-legend) as the process uses a set based on a existing names, not an array of all items.
By default the color in the legend will try to match the fill attribute or the stroke attribute of the relevant items. Color can be explicitly defined by attribute "data-legend-color"
The order of items in the legend will be sorted using the top of the bounding box for each included item. The order can be explicitly defined by attribute "data-legend-pos"
This is a fork of Interrupting Chained Transitions. It is showing the power of d3.dispatch for building reusable components.
A minimum spanning tree of the canvas is generated using randomized depth-first traversal. Hue encodes Manhattan distance from the start. (This is not an optimal visual encoding, but it suffices and is pretty.)
Randomized depth-first traversal can also be used to generate mazes. See a maze generated with randomized depth-first traversal flooded with color, and compare color floods of spanning trees generated by Prim’s algorithm, Wilson’s algorithm and random traversal.
Source: American Community Survey, 2011 5-Year Estimate
This map was inspired by a similar map found on Wikipedia. I wasn’t wild about the diverging color scale, so I thought it would be a fun challenge to recreate.
Finding the shapefiles was easy; I used the U.S. National Atlas 1:1,000,000 scale dataset, conveniently packaged in my U.S. Atlas repository. I reprojected the shapefiles to the California Albers projection using ogr2ogr:
ogr2ogr \
-f 'ESRI Shapefile' \
-t_srs 'EPSG:3310' \