sankeymatic icon indicating copy to clipboard operation
sankeymatic copied to clipboard

Allow upstream volume to be auto-calculated from sum of downstream volumes

Open kias-git opened this issue 8 years ago • 3 comments

Example flow

         3
12 <
         9

Here, if only 3 and 9 were specified, then sankeymatic calculates the 12.

kias-git avatar Mar 15 '16 06:03 kias-git

I'm not sure I follow - the Sankey algorithm from d3 already adds up all the inputs to a node to determine its total size.

Can you provide a sample SankeyMATIC input that doesn't work the way you want it to?

Example -- given:

A [3] B
A [9] C

the node A will automatically have size 12.

nowthis avatar May 29 '16 03:05 nowthis

True.. but it only works for one level.

Consider this, I have a three level stream (grandparent, parent, child) and all I specify are the amounts that each child needs. It looks like this:

Grandparent [X] Parent1
Grandparent [Y] Parent2
Parent1 [2] Child1
Parent1 [4] Child2
Parent2 [6] Child3
Parent2 [8] Child4

Calculating the amount X and Y is not automated. Here I would need to hardcode X=6 and Y=14. Instead I'd like not to have to specify the amounts in X and Y and let it be auto calculated. This is super important for doing a bottom-up flow rather than a top-down flow.

Doing a bottom up flow allows you to first enter the flows required at the leaf nodes and then based on the tree we can easily tell what flow each parent node needs.

kias-git avatar Jul 03 '16 06:07 kias-git

Aha, I think I understand now.

So, it would be nice to have a syntax that lets you say 'this flow should adopt the size of the mentioned target node'. My first thought was, using a wildcard character (*) would make some sense:

Grandparent [*] Parent1
Grandparent [*] Parent2
Parent1 [2] Child1
Parent1 [4] Child2
Parent2 [6] Child3
Parent2 [8] Child4

However, that might be too simple --

I could easily see someone thinking a catch-all grandchild node would be just as useful as a grandparent node, but if that is possible, then [*] will be ambiguous since using a simple wildcard character doesn't indicate direction (i.e. in this case, which node would adopt the volume of the other?):

node1 [*] node2

So maybe a directional hint would help:

node1 [<*] node2   ' node1 adopts node2's volume
node3 [*>] node4   ' node4 adopts node3's volume

So that would make the syntax for your example:

Grandparent [<*] Parent1
Grandparent [<*] Parent2

Does that seem like a viable/good-enough syntax?

I think that's a reasonable feature to add sometime. Unfortunately, I have several features queued up in front of it, so it may be a while. Patches are welcome, however.

nowthis avatar Jul 04 '16 16:07 nowthis