[ Launch: Tributary inlet ] 90bcb24d61d4c6b6ab4e by rkstedman
-
-
Save rkstedman/90bcb24d61d4c6b6ab4e to your computer and use it in GitHub Desktop.
benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"description":"benchmark","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/EmlQSQy.gif"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var results = {"my candidates":{"0":{"start":1400270725077,"end":1400270732641,"duration":7564},"mean":7564},"all candidates":{"0":{"start":1400270732641,"end":1400270736437,"duration":3796},"mean":3796},"on-site interview stage":{"0":{"start":1400270736437,"end":1400270742918,"duration":6481},"mean":6481},"full-time tag":{"0":{"start":1400270742918,"end":1400270746270,"duration":3352},"mean":3352},"view profile in offer stage":{"0":{"start":1400270746270,"end":1400270749146,"duration":2876},"mean":2876},"snooze list":{"0":{"start":1400270749146,"end":1400270752572,"duration":3426},"mean":3426}}; | |
var data = []; | |
for(var name in results) { | |
if(results.hasOwnProperty(name)) { | |
var datum = {name: name, mean: results[name].mean}; | |
data.push(datum); | |
} | |
} | |
data = [ { name: 'my candidates', duration: 6861.6 }, | |
{ name: 'all candidates', duration: 3151 }, | |
{ name: 'on-site interview stage', duration: 5089.4 }, | |
{ name: 'full-time tag', duration: 3496.6 }, | |
{ name: 'view profile in offer stage', duration: 3343.4 }, | |
{ name: 'snooze list', duration: 11650.6 } ]; | |
data.forEach(function(d) { | |
d.mean = +d.duration; | |
}); | |
var margin = {top: 20, right: 53, bottom: 30, left: 98}, | |
width = 405 - margin.left - margin.right, | |
height = 367 - margin.top - margin.bottom; | |
var svg = d3.select("svg"); | |
var g = svg.append("g") | |
.attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | |
var g2 = svg.append("g") | |
.attr("transform", "translate(" + 523 + "," + margin.top + ")"); | |
var bars = barChart() | |
.data(data) | |
.width(1000) | |
.height(400); | |
bars(g); | |
function barChart() { | |
var data = []; | |
var width = 600; | |
var height = 600; | |
var fontsize = "14px"; | |
var chart = function(g) { | |
var x = d3.scale.ordinal() | |
.rangeRoundBands([0, width], 0.1); | |
var y = d3.scale.linear() | |
.range([height, 0]); | |
var xAxis = d3.svg.axis() | |
.scale(x) | |
.orient("bottom"); | |
var yAxis = d3.svg.axis() | |
.scale(y) | |
.orient("left"); | |
x.domain(data.map(function(d) { return d.name; })); | |
y.domain([0, d3.max(data, function(d) { return d.mean; })]); | |
g.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + height + ")") | |
.call(xAxis); | |
g.append("g") | |
.attr("class", "y axis") | |
.call(yAxis) | |
.append("text") | |
.attr("transform", "rotate(-90)") | |
.attr("y", 6) | |
.attr("dy", "0.71em") | |
.style("text-anchor", "end") | |
.text("milliseconds") | |
.style("font-size", fontsize); | |
g.selectAll(".bar") | |
.data(data) | |
.enter().append("rect") | |
.attr("class", "bar") | |
.attr("x", function(d) { return x(d.name); }) | |
.attr("width", x.rangeBand()) | |
.attr("y", function(d) { return y(d.mean); }) | |
.attr("height", function(d) { return height - y(d.mean); }) | |
.style("fill", "#0B4F85"); | |
} | |
chart.data = function(value) { | |
if(!arguments.length) return data; | |
data = value; | |
return chart; | |
} | |
chart.width = function(value) { | |
if(!arguments.length) return width; | |
width = value; | |
return chart; | |
} | |
chart.height = function(value) { | |
if(!arguments.length) return height; | |
height = value; | |
return chart; | |
} | |
return chart; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment