Skip to content

Instantly share code, notes, and snippets.

@jkeohan
Last active June 17, 2016 14:37
Show Gist options
  • Select an option

  • Save jkeohan/e6f770d6f51707fccb9d to your computer and use it in GitHub Desktop.

Select an option

Save jkeohan/e6f770d6f51707fccb9d to your computer and use it in GitHub Desktop.
EUE - Circles
{"description":"EUE - Circles","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/wvqpXTB.png"}
var data1 = [1,2.5,3,4,5,6]
var data2 = [1,2,3,4,5]
var svg = d3.select('svg')
function render(data,color) {
var circles = svg.selectAll("circle").data(data)
//var circles = svg.selectAll("circle").data(data,function(d) {return d} )
circles.enter().append("circle")
.attr("cx", function(d,i) { return d * 60 } )
.attr("cy", 50)
.attr("r", 9)
.attr("fill",color)
circles.exit().remove()
}
render(data1,"blue")
render(data2,"green")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment