score:1

Accepted answer

I know this is a duplicate but I can't find one that matches so...

Never do a blind selectAll by element name:

svg.selectAll('rect')

There are other rect elements within your SVG that are being included causing strange behavior. Instead do:

svg.selectAll('.cell')
    .data(data)
    .enter()

This targets the selection to what you are really binding your data to.

Updated plunker.


Related Query

More Query from same tag