Skip to content

Instantly share code, notes, and snippets.

@k-izzo
Created March 21, 2014 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k-izzo/9679458 to your computer and use it in GitHub Desktop.
Save k-izzo/9679458 to your computer and use it in GitHub Desktop.
Tributary inlet
{"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12},"data.csv":{"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":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true}
start end dur type
2014-03-20 12:17:16 2014-03-20 12:52:16 35 general_d3
2014-03-20 14:12:33 2014-03-20 14:47:33 35 general_d3
2014-03-20 14:47:38 2014-03-20 15:10:30 22 general_d3
2014-03-20 16:38:59 2014-03-20 17:13:59 35 general_d3
2014-03-20 17:14:10 2014-03-20 17:49:11 35 general_d3
2014-03-20 18:15:50 2014-03-20 18:50:50 35 general_d3
2014-03-20 19:00:07 2014-03-20 19:35:07 35 general_d3
2014-03-20 21:47:43 2014-03-20 22:22:44 35 general_d3
2014-03-20 22:22:50 2014-03-20 22:51:52 29 general_d3
time = d3.time.format('%Y-%m-%d %H:%M:%S')
alter = (d) ->
d.start = time.parse(d.start)
d.end = time.parse(d.end[1...])
d.dur = +d.dur[1...]
d.type = d.type[1...]
data = tributary.data
data.forEach(alter)
w_scale = d3.scale.linear()
.domain([0, d3.max(data, (d) -> d.dur)])
.range([0, 400])
svg = d3.select('svg')
.append('g')
.attr('transform', 'translate(' + [21, 20] + ')')
svg.selectAll('rect')
.data(data)
.enter()
.append('rect')
.attr({
x: 94
y: (d, i) -> i*16 + 5
width: (d) -> w_scale(d.dur)
height: 12
})
svg.selectAll('text')
.data(data)
.enter()
.append('text')
.text((d) -> d.type)
.attr({
x: 0
y: (d, i) -> i*16
'alignment-baseline': 'hanging'
})
rect {
fill: #fd1562;
opacity: .5
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment