()
| 106 | } |
| 107 | |
| 108 | function renderHistogram() { |
| 109 | var histogram = module.sel.selectAll("div.histogram").data([stats.histogram]); |
| 110 | histogram.enter().append("div.histogram") |
| 111 | .on("mousemove", function() { |
| 112 | var mouseOffset = pixelsToPercentage(window.innerHeight)/100*this.offsetHeight / 2; |
| 113 | stats.windows.hover = pixelsToPercentage.invert(100 * (d3.mouse(this)[1] - mouseOffset) / this.offsetHeight); |
| 114 | renderWindows(); |
| 115 | }) |
| 116 | .on("mouseout", function() { |
| 117 | stats.windows.hover = null; |
| 118 | renderWindows(); |
| 119 | }) |
| 120 | .on("click", function() { |
| 121 | stats.windows.previous = stats.windows.current; |
| 122 | var mouseOffset = pixelsToPercentage(window.innerHeight)/100*this.offsetHeight / 2; |
| 123 | var target = pixelsToPercentage.invert(100 * (d3.mouse(this)[1] - mouseOffset) / this.offsetHeight); |
| 124 | d3.select("body").transition().duration(500) |
| 125 | .tween("smoothscroll", scrollTopTween(target)); |
| 126 | }); |
| 127 | |
| 128 | var windows = histogram.selectAll("div.window") |
| 129 | .data(Object.keys(stats.windows)); |
| 130 | |
| 131 | windows.enter() |
| 132 | .append("div.window") |
| 133 | .style("height", pixelsToPercentage(window.innerHeight)+"%") |
| 134 | .attr("data-window", _.identity); |
| 135 | renderWindows(); |
| 136 | |
| 137 | var bars = histogram.selectAll("div.bar") |
| 138 | .data(stats.histogram); |
| 139 | |
| 140 | bars.enter() |
| 141 | .append("div.bar") |
| 142 | .style("height", function(d) { return pixelsToPercentage(d.dx) + "%"; }) |
| 143 | .style("top", function(d) { return pixelsToPercentage(d.x) + "%"; }) |
| 144 | .on("click", function(d) { |
| 145 | d3.select("body").transition().duration(500) |
| 146 | .tween("smoothscroll", scrollTopTween(d.x)); |
| 147 | }); |
| 148 | |
| 149 | bars |
| 150 | .style("opacity", function(d) { return Math.min(d.y/15, 1); }); |
| 151 | |
| 152 | } |
| 153 | |
| 154 | function renderWindows() { |
| 155 | stats.windows.current = document.getElementsByTagName('body')[0].scrollTop; |
no test coverage detected