1

I'm wondering to what extent it is possible to tweak Sankey flow graphs in the package in R. I have the following sankeyNetwork graph:

library(networkD3)
states <- state.name[1:10]
ranks <- sample.int(10)
nodes <- data.frame(name = c(states, states[ranks]))
links <- data.frame(source = 1:10 - 1, target = order(ranks) + 10 - 1, value = 1)
sankeyNetwork(Links = links, Nodes = nodes, Source = 'source', 
          Target = 'target', Value = 'value', NodeID = 'name',
          iterations = 0)

I would like to replace the left- or right-hand side with bar charts. Something like this: Sankey Flow chart integrated with a bar chart Is there any way to integrate Sankey flow graphs with bar charts? I am absolutely willing to look into JavaScript but I'm not sure where to start. I'd appreciated if somone could point me to the right resources.

Ben
  • 197
  • 1
  • 9
  • There may be a way to do this one, but depending on the use case for this visual, it might be one where I'd build the two parts (bars and Sankey) separately, and then assemble it in Adobe Illustrator/Photoshop. You could definitely write custom Javascript to do this, but as someone who is not a JS developer, I'd question whether it's worth the effort - especially if it's a one-time chart. – Mako212 Sep 09 '18 at 05:45
  • `nodeWidth = 200` or something will make the nodes more bar-like, but you'd still have to figure out how to segment them. – Mako212 Sep 09 '18 at 05:46
  • That level of change/addition is way beyond what `networkD3` was intended for, which means at some point you spend more time fighting against it than getting any benefit from it. – CJ Yetman Sep 09 '18 at 07:53
  • If you’re interested in building sankey networks, or derivatives of that, in JavaScript/D3 (which is what `networkD3` is based on), this is the canonical starting point https://bost.ocks.org/mike/sankey/ – CJ Yetman Sep 09 '18 at 07:55

0 Answers0