Skip to content

Instantly share code, notes, and snippets.

@roundrobin
Created February 15, 2013 08:48
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 roundrobin/4959206 to your computer and use it in GitHub Desktop.
Save roundrobin/4959206 to your computer and use it in GitHub Desktop.
Path form
{"description":"Path form","endpoint":"","display":"svg","public":true,"require":[{"name":"Helpers","url":"https://raw.github.com/roundrobin/svg-path-generator/master/svg-path-generator.js"}],"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":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/TzygwMl.png"}
g.append("circle")
.attr({
r: 50,
cx: 57,
cy: 271,
fill: "#FF00FF",
id: 'handler1'
})
.datum({'output': '1'});
g.append("circle")
.attr({
r: 50,
cx: 229,
cy: 167,
fill: "#5CFF00",
'id': 'handler2'
})
.datum({'output': '2'})
g.append("circle")
.attr({
r: 50,
cx: 384,
cy: 131,
fill: "#00EBFF",
'id': 'handler3'
})
.datum({'output': '3'})
g.append("circle")
.attr({
r: 50,
cx: 517,
cy: 224,
fill: "#1F00FF",
'id': 'handler4'
})
.datum({'output': '4'});
var svg = d3.select('svg').node();
var pt = svg.createSVGPoint();
function cursorPoint(evt){
pt.x = evt.clientX; pt.y = evt.clientY;
return pt.matrixTransform(svg.getScreenCTM().inverse());
}
var text = g.append('text')
.text("Lorem Ipsum")
.attr("id","check")
.attr({
fill: "#000000",
x : 0,
y: 39,
"font-size": 32,
"font-family": "Arial",
"text-anchor": "start"
});
g.on('mousemove',function(){
var loc = cursorPoint(d3.event);
var d = document.elementFromPoint(d3.event.pageX, d3.event.pageY);
var el = d3.select(d);
if(el.node() && el.node().tagName == "circle"){
console.log(el.datum());
if(text.text().length >= 50){
text.text(" "+ el.datum()["output"])
} else {
text.text(text.text() +" "+ el.datum()["output"])
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment