Visit this site
I'm attempting to change all SVG images created using d3.select to grayscale by using the following function:
JavaScript:
<script>
function convert() {
d3.selectAll("image")
.style('filter', 'grayscale(100%)');
}
</script>
HTML:
<label id="label" style="display:inline;cursor:pointer;" onclick="convert();">
View in Grayscale</label>
The target items I want to affect were generated with:
var images = nodeEnter.append("svg:image")
.attr("xlink:href", function(d) { return d.path;})
.attr("x", function(d) { return -25;})
.attr("y", function(d) { return -25;})
.attr("height", 50)
.attr("width", 50);
While the function in the inspector seems to be correctly adding the filter style attribute for grayscale, the elements themselves are not changing to grayscale.
Any suggestions?