nowthis / sankeymatic

Make Beautiful Flow Diagrams
http://sankeymatic.com/build/
ISC License
841 stars 122 forks source link

How to place a node without children NOT in the rightmost position => How to completely hide a node? #36

Open Nemecsek opened 6 years ago

Nemecsek commented 6 years ago

This looks related to #11.

Using these data

A1 [100] B1
A2 [100] B1

A1 [100] B2

B1 [60] C1
B1 [60] C2
B1 [80] C3

I would like to align B2 to B1, even if it has no children.

Normally I get this: sankeymatic_300x300

but I would like to get this: sankeymatic_300x300 1

This could be easily solved if issue #35 has an answer: I would create a dummy node (say B2DUMMY) after B2, same value, transparent and flow set as "target" (so transparent). As the dummy node would have no text to show, it would be completely invisible.

In this example it is what I can get, but I need the the text B2DUMMY:100 to disappear:

A1 [100] B1
A2 [100] B1

A1 [100] B2

B1 [60] C1
B1 [60] C2
B1 [80] C3

B2 [100] B2DUMMY

:B2DUMMY #ffffff.0 >>

sankeymatic_300x300 2

Nemecsek commented 6 years ago

As partial solution, I modified the library to add to each node tag (A1, A2, etc) a node label ("Hall 1", "Hall 2", etc.). Now:

  1. The label can be multiline, with first line as title, as proposed in #35.
  2. Associating to a node tag an empty node label, no text is shown: in my case, "B2DUMMY: 100" just disappears.
  3. The values to print can be chosen programmatically, something very useful in my case because I need to print some extra data for each node.

Alas, I am a real newbie with JS and my solution has been greatly patched together without skill. Upon request I can provide the modified library: perhaps somebody could properly rewrite my poor code.

An example of sankey I am producing programmatically: sankey 13