Q:

How to append html element inside a function

This is the code I have from a function:
.text(function (d, i) { return data[i].label + " <tspan style='font-weight:700;'>(" + data[i].value + ")</tspan>" });

but it output MARCO &lt;tspan style='font-weight:700;'&gt;(7)&lt;/tspan&gt; and not MARCO <tspan style='font-weight:700;'>(7)</tspan>.
So it is not evalutate as HTML. Where do I should decode the text before "inject" it?

A:

Use html() instead of text(). text() will encode the string and add it in DOM.
.html(function (d, i) {
    return data[i].label + " <tspan style='font-weight:700;'>(" + data[i].value + ")</tspan>"
});

