d3_selectionPrototype.text = function(value) { return arguments.length < 1 ? this.node().textContent : this.each(typeof value === "function" ? function() { var v = value.apply(this, arguments); this.textContent = v == null ? "" : v; } : value == null ? function() { this.textContent = ""; } : function() { this.textContent = value; }); };
The important line here is that calling .text () to highlight will set the textContent property for each element. Therefore, the right thing in your case is to use
selection.text(' ');
So, if you want to use spaces, you just need to use spaces in the text, not encoded html spaces. If you want to use html encoded characters, you need to treat the content as innerHTML.
selection.html(' ');
Matt Esch Oct 14 '12 at 14:45 2012-10-14 14:45
source share