Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helping make NodePosX work #18

Open
NevilHopley opened this issue Jul 13, 2018 · 2 comments
Open

Helping make NodePosX work #18

NevilHopley opened this issue Jul 13, 2018 · 2 comments

Comments

@NevilHopley
Copy link

I have been using the sankeyD3 package to create SankeyNetworks and the 'NodePosX' feature isn't working for me yet.

To help illustrate the similar problem that I am having, I have edited the example from akraemer007 that was posted here to include the X positions of the nodes (see below) but it's still not working in the way that he had originally wanted, with manual control over the x-position of the 'Opted-Out' node.

Can someone please help identify the issue that I'm missing?
Thank you
Nevil

library(sankeyD3)
name <- c('Enrolled', 'Opted-Out', 'Invited', 'Activated')
xpos <- c(0, 1, 1, 2)
nodes <- data.frame(name, xpos)

source <- c(0, 0, 2, 1) 
target <- c(1, 2, 3, 3) 
value <- c(20, 80, 60, 0) 
links <- data.frame(source, target, value)
sankeyNetwork(Links = links, Nodes = nodes, Source = "source",
              Target = "target", Value = "value", NodeID = "name",NodePosX = "xpos",
              units = "TWh", fontSize = 12, nodeWidth = 30)
@NevilHopley NevilHopley changed the title Helping make NosPosX work Helping make NodePosX work Jul 13, 2018
@mp8
Copy link

mp8 commented Mar 31, 2020

One thing I have learned while using sankeyNetwork from netorkD3 is node orders (Y axis) is preserved when number of iterations =0. I tried your code with iterations = 0 and seems it preserve the specified NodePosX argument as well.

@SchmidtPaul
Copy link

SchmidtPaul commented Dec 22, 2021

I know I'm three years late but maybe this helps:

  • You had a 0 value which will lead to problems
  • NodePosX = "xpos" only works in combination with align = "none" or align = "left"
nodes <- data.frame(
  name = c("Enrolled", "Opted-Out", "Invited", "Activated"),
  xpos = c(0, 1, 2, 5)
)

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

sankeyD3::sankeyNetwork(
  Links = links,
  Nodes = nodes,
  Source = "source",
  Target = "target",
  Value = "value",
  NodeID = "name",
  fontSize = 12,
  NodePosX = "xpos",
  align = "none"
)

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants