I want to add a dollar sign to the link and node labels in a networkD3 Sankey plot. A similar question has be asked and answered here:
Link value label thousands separator
In the above link, CJ rewrites the link titles with htmlwidgets::onRender
to change the thousands separator from "," to ".".
I unfortunately do not understand JavaScript and can not figure out how to change the solution to fit my problem.
EDIT
Trying to apply CJ Yetman's technique to nodes. My code is not working.
customJS <- '
function(el,x) {
var node = d3.selectAll(".node");
var format = d3.format("($,.2f");
node.select("title").select("body")
.html(function(d) { return "<pre>" + d.target.name + "<br>" + format(d.value) + "<pre>"; });
}
'
Suggestions and corrections welcome.