When working with d3.js you can get into a situation where you have a text element that’s hard to read because of content in the background. Unfortunately you can’t add a background to the text element, but you can automatically add a rect with the same bounding box and position behind the text element. This rect element CAN have a fill to give your text the surface that separates it from the surrounding content.
I’ve created a handy helper method that you can use to automagically give your text nodes the necessary background.