Skip to content

Instantly share code, notes, and snippets.

@erhangundogan
Created December 8, 2013 22:33
Show Gist options
  • Select an option

  • Save erhangundogan/7864719 to your computer and use it in GitHub Desktop.

Select an option

Save erhangundogan/7864719 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>d3 js beginning</title>
<style>
.pos {
position:absolute;
font-size:48pt;
position: absolute;
right: 40%;
bottom: 50%;
}
.panel {
background:#FFF;
width:100%;
height:100%;
position:relative;
}
body, html {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
<script src="http://d3js.org/d3.v3.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="c" class="panel">
<div id="pos" class="pos"></div>
</div>
<script>
d3.select("div#c").on("mousemove", function(a, b){
var msg = "X:" + d3.event.clientX + " Y:" + d3.event.clientY;
d3.select("div#pos").text(msg);
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment