I am a bit astonished because I seem not to be able to find a way to add a rect so it gets an id or class as well.
I am building (quite a lot of) rectangles programmatically by the code like below:
var svg = d3.select("#diagram")
.append("svg")
.attr("width", 450)
.attr("height", 600);
$.each(data_val, function(form_key,form_val){
$.each(form_val, function(person_key,person_val){
svg.append("rect")
.attr("x", start*2*width+width-5)
.attr("y", 420-person_val.loads/person_val.load_max*400)
.attr("width", width-5)
.attr("height", person_val.loads/person_val.load_max*400)
.style("fill", "#ba122b");
}
}
I would very much to add id (and/or) class like here:
svg.append("rect")
.attr("x", start*2*width+width-5)
.attr("y", 420-person_val.loads/person_val.load_max*400)
.attr("width", width-5)
.attr("height", person_val.loads/person_val.load_max*400)
.attr("id",$good_id_value)
.style("fill", "#ba122b");
or
svg.append("rect")
.attr("x", start*2*width+width-5)
.attr("y", 420-person_val.loads/person_val.load_max*400)
.attr("width", width-5)
.attr("height", person_val.loads/person_val.load_max*400)
.id($good_id_value)
.style("fill", "#ba122b");
But, the problem is that it doesn't work, nothing else wrong with it.
Am I missing something, just dumb or dumb but on higher level?
hank