christophergandrud / networkD3

D3 JavaScript Network Graphs from R
http://christophergandrud.github.io/networkD3
649 stars 270 forks source link

Node IDs with spaces cause issues assigning color #293

Closed Ferdinandinio closed 2 years ago

Ferdinandinio commented 2 years ago

Hello, apparently networkd3 is having issues assigning colors to nodes correctly if the node IDs (node names) contain spaces. E.g. if two different nodes were called "Example One" and "Example Two", they would be assigned the same color because it appears to only read "Example". If all the names of the nodes were to start with a space, they are all assigned the same color because it apparently only reads the space. This brings me to another (connected) issue, which is that there is no spacing between the NodeID and the value, when hovering over the Links or Nodes. I added the space to the NodeIDs as a workaround, which caused the prior issue.

Best regards

cjyetman commented 2 years ago

This is a known limitation that has been asked/discussed on StackOverflow many times, e.g. https://stackoverflow.com/questions/69316891/how-to-fix-incorrect-color-for-nodes-in-networkd3-sankeynetwork https://stackoverflow.com/questions/68449073/sankey-networkd3-set-link-colours-across-entire-flow https://stackoverflow.com/questions/70723459/override-default-networkd3-graph-properties https://stackoverflow.com/questions/48796238/custom-colors-for-networkd3-sankeygraph

This package is not really actively maintained, so I wouldn't hold my breath for any changes to be made internally.