Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Last active August 29, 2015 14:14
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 ramnathv/68fd18ed731acccb1be8 to your computer and use it in GitHub Desktop.
Save ramnathv/68fd18ed731acccb1be8 to your computer and use it in GitHub Desktop.
Experiments
{"description":"Experiments","endpoint":"","display":"div","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.coffee":{"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/ZOm95Ie.png"}
svg = d3.select("#display")
.append("svg")
.attr({width: 400, height: 200})
circles = svg.selectAll('circle')
.data(data, (d) -> d)
circles.enter()
.append('circle')
.attr('cx', (d) -> d*20 +50)
.attr('cy', 100)
.attr('r', (d) -> d)
###
update = () ->
circles = svg.selectAll("circle")
.data([3, 4, 6, 9, 12], (d) -> d)
circles.enter()
.append('circle')
.attr('cx', (d) -> d*20 +50)
.attr('cy', 100)
.attr('r', (d) -> d)
circles.exit().remove()
btn = d3.select("#display")
.append("button")
.text("Update")
.on("click", update)
###
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment