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

Possible infinite loop in sankey generator #50

Closed
ghost opened this issue Jan 6, 2018 · 2 comments
Closed

Possible infinite loop in sankey generator #50

ghost opened this issue Jan 6, 2018 · 2 comments

Comments

@ghost
Copy link

ghost commented Jan 6, 2018

I believe I have found an infinite loop behavior in the sankey generator. To reproduce it, I'm calling the sankey generator multiple times with different data (different nodes and links). If you could see the code that I have attached, the slider freezes when it reaches the year 2004 (actually, I don't know why 2004, the data is similar to all the others). The sankey function is called in line 22 of sankey_migration.js

Thank you for d3js and sankey.

sankey_migration_infinite_loop.zip

@ghost
Copy link
Author

ghost commented Jan 6, 2018

Yes, I believe I've found the problem, there's a circular reference on the links, going from 0 to 3 and 3 to 0.

{ "source": 0, "target": 3, "value": 63.16 },
{ "source": 3, "target": 0, "value": 14.099 }

So, the mistake it's on this side (now I have to think how to resolve it).
Everything should be fine with d3-sankey.

{
			"nodes": [
				{ "name": "Portugal" },
				{ "name": "Switzerland" },
				{ "name": "Germany" },
				{
					"name":
						"United Kingdom of Great Britain and Northern Ireland"
				},
				{ "name": "Luxembourg" },
				{ "name": "Belgium" },
				{ "name": "Cabo Verde" },
				{ "name": "Brazil" },
				{ "name": "Angola" },
				{ "name": "Guinea Bissau" }
			],
			"links": [
				{ "source": 0, "target": 1, "value": 135.449 },
				{ "source": 0, "target": 2, "value": 133.726 },
				{ "source": 0, "target": 3, "value": 63.16 },
				{ "source": 0, "target": 4, "value": 58.657 },
				{ "source": 0, "target": 5, "value": 25.636 },
				{ "source": 6, "target": 0, "value": 48.984 },
				{ "source": 7, "target": 0, "value": 23.921 },
				{ "source": 8, "target": 0, "value": 21.231 },
				{ "source": 9, "target": 0, "value": 16.375 },
				{ "source": 3, "target": 0, "value": 14.099 }
			]
		}

Best regards,

@mbostock
Copy link
Member

mbostock commented Jan 6, 2018

Duplicate of #1.

@mbostock mbostock closed this as completed Jan 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant