Skip to content

Order is not uniform across the diagram #62

@sildar

Description

@sildar

Hi!

While drawing sankey diagrams, I often want to have coloring depending on type, and keep those colors all the way through the diagram. While this feature exists, it does not seem to be compatible with the order parameter.

Here's a minimal example of what I mean:

links = [{"source": "A", "target": "1", "value": 5, "type": "A"},
         {"source": "B", "target": "1", "value": 10, "type": "B"},
         {"source": "C", "target": "1", "value": 15, "type": "C"},
         {"source": "1", "target": "2", "value": 5, "type": "A"},
         {"source": "1", "target": "2", "value": 10, "type": "B"},
         {"source": "1", "target": "2", "value": 15, "type": "C"}]

w = SankeyWidget(links=links)
w

image

This works well, but if I want to change the ordering of, say, A and B, I can write this:

links = [{"source": "A", "target": "1", "value": 5, "type": "A"},
         {"source": "B", "target": "1", "value": 10, "type": "B"},
         {"source": "C", "target": "1", "value": 15, "type": "C"},
         {"source": "1", "target": "2", "value": 5, "type": "A"},
         {"source": "1", "target": "2", "value": 10, "type": "B"},
         {"source": "1", "target": "2", "value": 15, "type": "C"}]

order = [
         ["B", "A", "C"],
         ["1"],
         ["2"]
]

w = SankeyWidget(links=links, order=order)
w

image

While this works, the ordering is only defined for the first layer, and the next one (between "1" and "2") is not impacted by the order parameter, making the diagram harder to read. I can't find a way to keep the ordering consistent in subsequent layers, am I missing something? I tried changing the ordering of the links structure, thinking first entries get drawn first (ie switching lines 4 and 5), but unfortunately this is not the case.

Is there any solution?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions