Skip to content

Instantly share code, notes, and snippets.

@RobinL
Created April 24, 2013 20:05
Show Gist options
  • Save RobinL/5455132 to your computer and use it in GitHub Desktop.
Save RobinL/5455132 to your computer and use it in GitHub Desktop.
on click
{"description":"on click","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"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}
svg = d3.select("svg");
csv = [
{"row ID": "id1",
"x": 20,
"y": 30},
{"row ID": "id2",
"x": 30,
"y": 50}
]
svg.selectAll("circle").data(csv).enter().append("circle")
.attr("id", function(d){return "row"+d["ROW ID"];})
.attr("cx", function(d){return d.x})
.attr("cy",function(d){return d.y})
.attr("r",10)
.style("fill", "black");
circles = d3.selectAll("circle");
circles.on("click",function(d) {
alert(d["row ID"]);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment