index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>d3 drop shadow example</title>
</head>
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
width: 960px;
height: 500px;
position: relative;
}
</style>
<body>
<h4>Look ma, drop shadows!</h4>
<p>Zoom in to see how pretty they are.</p>
<div id="chart">
</div>
<script src="//d3js.org/d3.v3.min.js"></script>
<script type="text/javascript" src="dropshadow.js"></script>
</body>
</html>
dropshadow.js
var items = [
{x : 50, y : 10},
{x : 100, y: 170},
{x : 320, y: 70}
];
var w=960,h=500,
svg=d3.select("#chart")
.append("svg")
.attr("width",w)
.attr("height",h);
var defs = svg.append("defs");
var filter = defs.append("filter")
.attr("id", "drop-shadow")
.attr("height", "130%");
filter.append("feGaussianBlur")
.attr("in", "SourceAlpha")
.attr("stdDeviation", 5)
.attr("result", "blur");
filter.append("feOffset")
.attr("in", "blur")
.attr("dx", 5)
.attr("dy", 5)
.attr("result", "offsetBlur");
var feMerge = filter.append("feMerge");
feMerge.append("feMergeNode")
.attr("in", "offsetBlur")
feMerge.append("feMergeNode")
.attr("in", "SourceGraphic");
var item = svg.selectAll("rect")
.data(items)
.enter().append("rect")
.attr("width", 170)
.attr("height", 100)
.attr("fill", "steelblue")
.attr("stroke-width", 2)
.style("filter", "url(#drop-shadow)")
.attr("transform", function(d) { return "translate(" + d.x + "," + d.y + ")"; });