fbreitwieser / sankeyD3

D3 Sankey Network Graphs from R
65 stars 27 forks source link

Linebreaks in node label? #25

Open SchmidtPaul opened 2 years ago

SchmidtPaul commented 2 years ago

So far, I've tried these, but they don't seem work:

\n
\r
<br/>

Here's a reprex:

links <- data.frame(
  source = c(0, 0, 1, 2),
  target = c(1, 2, 3, 3),
  value = c(10, 20, 10, 20)
)

nodes <- data.frame(
  label = c("I am using \n in this string",
            "I am using \r in this string",
            "I am using <br/> in this string",
            "I am using
            in this string")
)

sankeyD3::sankeyNetwork(
  Links = links,
  Nodes = nodes,
  Source = "source",
  Target = "target",
  Value  = "value",
  NodeID = "label",
  numberFormat = ",.0f",
  fontFamily = "Arial",
  fontSize = 12,
  width  = 400,
  height = 300)

Created on 2021-12-22 by the reprex package (v2.0.1)