Accepted answer

You're assigning the rectangle's attributes to the group (i.e, svg:g) beneath it. In the line below, remove the .append("svg:g") and it should work.


Also, you're setting opacity to zero:

.attr('opacity', 0)

This makes your rectangle invisible. Set it to 1 instead for full visibility, or some number in between for a translucent fill effect.

Related Query

More Query from same tag