I am trying to create this concept with d3js and angular:
An important aspect is that I want to add covers inside a bar. After doing a lot research I still haven't figured out how to do this with a svg. I am hoping to get some advice on this over here.
This is a piece of code that comes close I believe, but the image is only present in the dom and not visible on top of the bar:
svg.selectAll(".bar")
.data(data)
.enter().append("rect")
.attr("class", "bar")
.attr("x", function(d) { return x(d.letter); })
.attr("width", x.rangeBand())
.attr("y", function(d) { return y(d.frequency); })
.attr("height", function(d) { return height - y(d.frequency); })
.on('click', function(d, i) {
d3.select(this).style("fill", "red");
d3.select(this).append("svg:image")
.attr("xlink:href", "http://www.e-pint.com/epint.jpg")
.attr("width", 50)
.attr("height", 70)
.attr("x", 0)
.attr("y", 0)
});
Thanks,
Also any additional comments about this concept and the execution with D3 are welcome
EDIT:
New tryout according to the question posted in the second comment:
.on('click', function(d, i) {
d3.select(this)
.append("defs").attr('id', 'aap');
svg.select("#aap").append("pattern")
.attr('x', '0')
.attr('y', '0')
.attr("height","200")
.attr('width', "200")
.attr("id", "cover");
svg.select("#cover")
.append("svg:image")
.attr("xlink:href", "http://www.e-pint.com/epint.jpg")
.attr("width", 100)
.attr("height", 200)
.attr("x", 0)
.attr("y", 0)
});
For somehow now area in the dom is highlighted blue when I hover over it in the inspector: