[ Launch: we dont have time to argue about time ] 6759093 by gelicia
[ Launch: we dont have time to argue about time ] 5602911 by gelicia
-
-
Save gelicia/6759093 to your computer and use it in GitHub Desktop.
we dont have time to argue about time
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":"we dont have time to argue about time","endpoint":"","display":"svg","public":true,"require":[{"name":"momentjs","url":"https://rawgithub.com/moment/moment/2.2.1/min/moment.min.js"}],"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},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/aW5Pgp2.png"} |
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
//6694952 | |
//6708450 | |
//6411197 | |
var gistID = "6411197"; | |
var urlBase = "http://tributary.io"; | |
var url = urlBase + "/api/inlet/" + gistID; | |
d3.json(url, function(err, inlets) { | |
render(inlets); | |
}); | |
function render(inlets){ | |
//put all related gists in an array so it's easier to iterate through | |
var inletArr = []; | |
var inlet = inlets; | |
var parent = inlet.parent; | |
while(parent !== undefined){ | |
delete inlet.parent; | |
inletArr.push(inlet); | |
inlet = parent; | |
parent = inlet.parent; | |
} | |
//push the root inlet | |
inletArr.push(inlet); | |
inletArr = inletArr.map(function(d){ | |
d.createdAt = moment(d.createdAt);//.toDate(); | |
d.lastSave = moment(d.lastSave);//.toDate(); | |
return d; | |
}); | |
//style | |
var sideMar = 47; | |
var margin = {top: 68, left: sideMar, right: sideMar}; | |
var svg = d3.select('svg'); | |
svg.append('line') | |
.attr({ | |
x1: margin.left, | |
y1: margin.top, | |
x2: tributary.sw - (margin.right+margin.left), | |
y2: margin.top, | |
"stroke": "black" | |
}); | |
var timeExtent = d3.extent(inletArr, function(d){ return d.createdAt;}); | |
var timeScale = d3.time.scale().domain(timeExtent).range([margin.left, tributary.sw - (margin.left + margin.right)]); | |
var monthAxis = d3.svg.axis().scale(timeScale) | |
.tickFormat(d3.time.format("%b")) | |
.ticks(d3.time.months, 1); | |
var yearAxis = d3.svg.axis().scale(timeScale) | |
.tickFormat(d3.time.format("%Y")) | |
.ticks(d3.time.years, 1) | |
svg.append("g") | |
.attr({ | |
"transform": "translate(0," + (margin.top - 35) + ")", | |
"class": "scaleStyle" | |
}) | |
.call(monthAxis); | |
svg.append("g") | |
.attr({ | |
"transform": "translate(0," + (margin.top - 60) + ")", | |
"class": "yearStyle" | |
}) | |
.call(yearAxis); | |
var circles = svg.selectAll('circle') | |
.data(inletArr).enter() | |
.append("circle") | |
.attr({ | |
cx: function(d){return timeScale(d.createdAt);}, | |
cy: margin.top, | |
r: 7, | |
stroke: "black", | |
fill: "steelblue" | |
}); | |
console.log(inletArr); | |
circles.append('title') | |
.text(function(d, i){ return d.description + ": " + d.createdAt.format('DD-MM-YYYY') + " by " + d.user.login;}); | |
} |
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
.scaleStyle path, | |
.scaleStyle line { | |
fill: none; | |
} | |
.scaleStyle{ | |
font-size: 15px | |
} | |
.yearStyle path, | |
.yearStyle line { | |
fill: none; | |
} | |
.yearStyle{ | |
font-weight:bold; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment