var width = 960, height = $ , r = + ;
??
var data = [
[Width/ 2 -R, Height/ 2 -R],
[Width/ 2 -R, Height/ 2 + R],
[Width/ 2 + R, Height/ 2 -R],
[Width/ 2 + R, Height/ 2 + R]
];
??
var svg = d3.select ("Body"). Append ("SVG")
. attr ("width", width)
. attr ("height", height)
. Append ("G");
??
var drag = D3.behavior.drag () //<-a
. On ("Drag", move);
??
Svg.selectall ("Circle")
. Data (data)
. Enter (). Append ("Circle")
. attr ("R", R)
. attr ("transform", function (d) {
return " Translate (" + D + ")";
})
. Call (drag); //<-a
??
function move(d) {
var x = d3.event.x, //<-c
y = d3.event.y;
??
If(inboundaries(x, y))
D3.select (This)
. attr ("transform", function (d) { //<-d
return " Translate (" + x + "," + y + ")";
});
}
?
function inboundaries(x, y) {
return (x >= (0 + R) && x <= (width-r))
&& (y >= (0 + R) && y <= (height-r));
}
??
The glitz and Sansheng dreams of the First world.
Glitz
??
function Test () {
Console.log (My)
}
? ?
OneNote Blog Release test