[ Launch: foobar bumplesnork ] 6738134 by gelicia
-
-
Save gelicia/6738134 to your computer and use it in GitHub Desktop.
foobar bumplesnork
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":"foobar bumplesnork","endpoint":"","display":"svg","public":true,"require":[{"name":"moment","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},"ferreal.js":{"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,"thumbnail":"http://i.imgur.com/ixAYfAg.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
// Modified from: http://stackoverflow.com/questions/4450837/javascript-string-to-date-php-iso-string-format | |
// Thank you Roman Dvornov | |
Date.fromISOString = (function(){ | |
var tzoffset = (new Date).getTimezoneOffset(); | |
function fastDateParse(y, m, d, h, i, s, ms){ // this -> tz | |
return new Date(y, m - 1, d, h || 0, +(i || 0) - this, s || 0, ms || 0); | |
} | |
// result function | |
return function(isoDateString){ | |
var tz = isoDateString.substr(10).match(/([\-\+])(\d{1,2}):?(\d{1,2})?/) || 0; | |
if (tz) { | |
tz = tzoffset + (tz[1] == '-' ? -1 : 1) * (tz[3] != null ? +tz[2] * 60 + (+tz[3]) : +tz[2]); | |
} else { | |
tz = tzoffset; | |
} | |
return fastDateParse.apply(tz || 0, isoDateString.split(/\D/)); | |
} | |
})(); |
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 gistID = "6694952"; | |
var urlBase = "http://tributary.io"; | |
var url = urlBase + "/api/inlet/" + gistID; | |
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" | |
}); | |
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); | |
var dateParse = d3.time.format("%m/%Y").parse; | |
inletArr = inletArr.map(function(d){ | |
//I know, I'm sorry, ISO to date is not easy. | |
d.createdAt = moment(d.createdAt).toDate(); | |
d.lastSave = moment(d.lastSave).toDate(); | |
return d; | |
}); | |
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)]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment