Place text values to right of sankey diagram
<p>Is there a trick to placing text on a sankey diagram rendered using networkD3?  I would like to have the values of the endpoints be displayed as text to the right of their boxes.  I realize that hovering over the boxes displays the value, but as the boxes get smaller it would be much easier in many cases to portray the information if the values were always visible on the side.</p>

<p>Here is an example; I was able to kinda hack it by adding the values as part of the labels, but it would be much better to have the values displayed to the right of the diagram.</p>

<pre><code>library(networkD3)
library(data.table)
set.seed(1999)
links &lt;- data.table(
  src = rep(0:4, times=c(1,1,2,3,5)),
  target = sample(1:11, 12, TRUE),
  value = sample(100, 12)
)[src &lt; target, ]  # no loops
nodes &lt;- data.table(name=LETTERS[1:12])

## Need to hover to get counts
sankeyNetwork(Links=links, Nodes=nodes, Source='src', Target='target',
  Value='value', NodeID='name', fontSize=16)

## Add text to label
txt &lt;- links[, .(total = sum(value)), by=c('target')]
nodes[txt$target+1L, name := paste0(name, ' (', txt$total, ')')]

## Displays the counts as part of the labels
sankeyNetwork(Links=links, Nodes=nodes, Source='src', Target='target',
  Value='value', NodeID='name', fontSize=16, width=600, height=300)
</code></pre>

<p><a href="https://i.stack.imgur.com/f3NMN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/f3NMN.png" alt="enter image description here"></a></p>