Created
September 26, 2012 16:41
-
-
Save bsr203/3789099 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>test</title> | |
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 410 250"> | |
<defs> | |
<filter id="dropshadow" height="130%"> | |
<feGaussianBlur in="SourceAlpha" stdDeviation="3"/> | |
<feOffset dx="2" dy="2" result="offsetblur"/> | |
<feMerge> | |
<feMergeNode/> | |
<feMergeNode in="SourceGraphic"/> | |
</feMerge> | |
</filter> | |
</defs> | |
</svg> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<style type="text/css"> | |
text { | |
font: 10px sans-serif; | |
} | |
.myclass { | |
stroke: #000; | |
} | |
rect { pointer-events: painted; } | |
rect:hover { filter: url(#dropshadow); } | |
</style> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
var dataset = [{"coord": {"Y": 80, "X": 40, "W": 50, "H": 30}, "class": "test"}, | |
{"coord": {"Y": 80, "X": 100, "W": 50, "H": 30}, "class": "test"}] | |
function click(d, i) { | |
console.log(".... click ..... ") | |
} | |
var svg = d3.select("svg") | |
svg.selectAll("rect") | |
.data(dataset) | |
.enter() | |
.append("svg:rect") | |
.attr("x", function(d) { return d.coord.X}) | |
.attr("y", function(d) { return d.coord.Y}) | |
.attr("height", function(d) { return d.coord.W}) | |
.attr("width", function(d) { return d.coord.H}) | |
//.attr("class", function(d) { return "myclass " + d.class }) | |
.on("click", click); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment