Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

[sankey.js] nodesByBreadth not sorting numerically #131

Open
avocadostorm opened this issue May 14, 2015 · 0 comments
Open

[sankey.js] nodesByBreadth not sorting numerically #131

avocadostorm opened this issue May 14, 2015 · 0 comments

Comments

@avocadostorm
Copy link

Not sure if this is something you intended but it caused me some issues. d3.ascending used as the sort key here doesn't sort the "columns" of the sankey diagram in numerical order (d3.ascending is a natural ordering iirc). So if you are trying to do operations right-to-left or reversed, it doesn't work.

var nodesByBreadth = d3.nest()
        .key(function(d) { return d.tier; }) //originally d.x; I added a "tier" int index
        .sortKeys(d3.ascending) //using this the tiers are ordered 0, 1, 10, 2, 3 ... 
        .entries(nodes)
        .map(function(d) { return d.values; });

I swapped out your d3.ascending with a numerical ordering (identical except casting a and b to Numbers) and the "tiers" were then sorted in numerical order. Probably not a big deal but it seemed counter to your intent with this data structure.

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

No branches or pull requests

1 participant