Created
September 26, 2012 11:32
-
-
Save bsr203/3787476 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> | |
<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("body").append("svg") | |
.attr("width", 400) | |
.attr("height", 300); | |
var filter = svg.append("svg:defs") | |
.append("svg:filter") | |
.attr("id", "dropshadow") | |
.append("svg:feGaussianBlur") | |
.attr("stdDeviation", 0); | |
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