selection.text(\' \')
appears to convert the special characters so it renders the actual text, rather than a space like I want. Is there a way to prev
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() on a selection will set the textContent property on each element. So the correct thing to do in your case is use
selection.text(' ');
So if you want to use spaces then you simply have to use spaces in the text, not html encoded spaces. If you want to use html encoded chars then you have to treat the content as innerHTML.
selection.html(' ');
Use a JavaScript Unicode escape rather than an HTML entity.
in HTML denotes the Unicode character U+00A0 so
selection.text('\u00A0')
should do what you want.