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

[sankey.js] nodesByBreadth not sorting numerically #131

@avocadostorm

Description

@avocadostorm

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions