D3 Heatmap

HTML

<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/3.6.0/lodash.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/d3-tip/0.6.3/d3-tip.min.js"></script>
<script src="//rawgit.com/mpschr/129c671ee44a417c417e/raw/60224d8d9c9457665b126101788cfb68efc7ac0b/legend.js"></script>
<div id="chart" style='float:left;'></div>
<div id="annotation" style='float:left;'></div>

CSS

.axis line {
  fill: none;
  stroke: black;
  shape-rendering: crispEdges;
}

.axis path{
  display: none;
}

.y.axis text {
    font-size: 6px;
}
.y.axis text:hover {
    font-size: 24px;
}

.axis text {
  font-family: sans-serif;
  font-size: 11px;
}

.d3-tip {
  line-height: 1;
  font-weight: normal;
  font-size: 14px;
  padding: 8px; /* 12px */
  background: rgba(0, 0, 0, 0.8);
  color: #f00;
  border-radius: 2px;
  pointer-events: none;
}

.d3-tip.light {
  padding: 10px;
  background-color: white;
  color: #ff0;
  -webkit-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
  -moz-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
  box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
}

/* Creates a small triangle extender for the tooltip */
.d3-tip:after {
  box-sizing: border-box;
  display: inline;
  font-size: 10px;
  width: 100%;
  line-height: 1;
  color: rgba(0, 0, 0, 0.8);
  position: absolute;
  pointer-events: none;
}

.d3-tip.light:after{
  color: #fff;
}

/* Northward tooltips */
.d3-tip.n:after {
  content: "\25BC";
  margin: -1px 0 0 0;
  top: 100%;
  left: 0;
  text-align: center;
}

/* Eastward tooltips */
.d3-tip.e:after {
  content: "\25C0";
  margin: -4px 0 0 0;
  top: 50%;
  left: -8px;
}

/* Southward tooltips */
.d3-tip.s:after {
  content: "\25B2";
  margin: 0 0 1px 0;
  top: -5px;
  left: 0;
  text-align: center;
}

/* Westward tooltips */
.d3-tip.w:after {
  content: "\25B6";
  margin: -4px 0 0 -1px;
  top: 50%;
  left: 100%;
}

#annotation {
  margin: 50px;
  padding: 15px;
  min-width: 100px;
  min-height: 50px;
  background: whitesmoke;
}

CoffeeScript

breaks = [0,0,100,200,300,400,500,600,700,800,4870.9677,8941.9355,13012.9032,17083.871,21154.8387,25225.8065,29296.7742,33367.7419,37438.7097,41509.6774,45580.6452,49651.6129,53722.5806,57793.5484,61864.5161,65935.4839,70006.4516,74077.4194,78148.3871,82219.3548,86290.3226,90361.2903,94432.2581,98503.2258,102574.1935,106645.1613,110716.129,114787.0968,118858.0645,122929.0323,127000]

cols = ["#FFFFFF","#EDF3FD","#DCE7FB","#CBDBF9","#BACFF7","#A8C4F5","#97B8F3","#86ACF1","#75A0EF","#6495ED","#FFFF00","#FFF600","#FFED00","#FFE400","#FFDB00","#FFD300","#FFCA00","#FFC100","#FFB800","#FFAF00","#FFA700","#FF9E00","#FF9500","#FF8C00","#FF8300","#FF7B00","#FF7200","#FF6900","#FF6000","#FF5700","#FF4F00","#FF4600","#FF3D00","#FF3400","#FF2B00","#FF2300","#FF1A00","#FF1100","#FF0800","#FF0000"] 

obj2table = (data) ->
  table = ["<table class='table table-condensed table-striped'>"]
  d3.entries(data).forEach (d) ->
    table.push("<tr><td>" + d.key + "</td><td>&nbsp</td><td>" + d.value + "</td></tr>")
  table.join("") + "</table>"

data =...