Skip to content

Instantly share code, notes, and snippets.

@killfill
Created August 3, 2013 18:26
Show Gist options
  • Save killfill/6147467 to your computer and use it in GitHub Desktop.
Save killfill/6147467 to your computer and use it in GitHub Desktop.
broked
{"description":"broked","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":true,"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/63fGAmb.png"}
var id = 0;
var svg = d3.select('svg'),
data = [{x: 500, id: id++}, {x: 230, id: id++}, {x: 200, id: id++}, {x: 400, ud:id++}]
function tick() {
data.push({x: 500 - 10* Math.random(), id: id++})
var sel = svg.selectAll('circle').data(data, function(d) {return d.id})
sel.enter()
.append('circle')
.attr({cx: function(d) {return d.x;}, cy: 100, r: 8})
sel.exit().remove()
sel.transition()
.attr('cx', function(d) {d.x -= 30; return d.x})
if (data.length>8)
data.shift()
}
//huh?
var t = new Date().getTime()
tributary.run = function(g, ts) {
var now = new Date().getTime();
if (now - t < 700) return;
t = now;
tick();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment