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

Edge data #7

Open
psychemedia opened this issue Mar 16, 2017 · 1 comment
Open

Edge data #7

psychemedia opened this issue Mar 16, 2017 · 1 comment

Comments

@psychemedia
Copy link

psychemedia commented Mar 16, 2017

Does the edge data require that the nodes are identified as consecutive integers, starting from 0?

eg this works:

cc=data.frame(source=c(0,1,2),target=c(3,4,5),value=c(10,15,20))
cn=data.frame(name=c('a','b','c','d','e','f'))
sankeyNetwork(Links = cc, Nodes = cn, Source = "source", Target = "target", Value = "value", NodeID = "name",  fontSize = 12, nodeWidth = 30)

but if I try:

 cc=data.frame(source=c(6,1,2),target=c(3,4,5),value=c(10,15,20))

or

cc=data.frame(source=c(0,1,2),target=c(4,5,6),value=c(10,15,20))

or

cc=data.frame(source=c(0,1,2),target=c('x','y','z'),value=c(10,15,20))

the chart doesn't render?

UPDATE: I think @timelyportfolio's Sankey plot uses the following to get round the index issue:

//FROM: http://bl.ocks.org/timelyportfolio/79350d7475a5709b051e
//it appears d3 with force layout wants a numeric source and target
//so loop through each link replacing the text with its index from node
links.forEach(function (d, i) {
    links[i].source = nodes.indexOf(links[i].source);
    links[i].target = nodes.indexOf(links[i].target);
});
@fbreitwieser
Copy link
Owner

Indeed currently it does require that. I'll think about the work-around from @timelyportfolio .

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

2 participants