Skip to content

Instantly share code, notes, and snippets.

@scottix
Last active December 18, 2015 23: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 scottix/5863845 to your computer and use it in GitHub Desktop.
Save scottix/5863845 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<title>Drag Rect</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.min.js"></script>
</head>
<body>
<script type="text/javascript">
var w = 500;
var h = 400;
//setup svg canvas
d3.select("body")
.append("svg:svg")
.attr("width", w)
.attr("height", h)
.attr("id", "charts")
.append("svg:rect")
.attr("width", "300")
.attr("height", "200")
.attr("stroke", "#000")
.attr("fill", "white")
.call(d3.behavior.drag()
.on('dragstart', function() {
console.log(0);
})
.on('drag', function() {
console.log(1);
})
.on('dragend', function() {
console.log(2);
})
);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment