I'm having issues changing the rectangles in sankeyNetwork into circles in the networkd3 package for R. So far my onrender js code only removes the rectangles, not sure why the circles aren't being added instead.
Here's my code:
htmlwidgets::onRender(
p,
'
function(el,x){
//node variable
var node=d3.select(el).select("svg").selectAll(".node");
//remove node
node.selectAll("rect")
.remove();
// add circles instead
node
.append("circle")
.attr("cx",sankey.nodeWidth()/2)
.attr("cy",function(d){
return d.dy/2;
})
.attr("r",function(d){
return Math.sqrt(d.dy);})
.style("fill", function(d) {
return d.color = color_node(d); })
.style("stroke", function(d) { return d3.rgb(d.color).darker(2); })
.style("opacity", 0.9)
.style("cursor", "move")
.append("title")
.append("foreignObject")
.append("xhtml:body")
.html(function(d) { return "<pre>" + d.name + "<br>" + format(d.value) +
" " + options.units + "</pre>"; })
;
}
'
)