nowthis / sankeymatic

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

hide labels starting with a '*' #64

Closed KaiHomeier closed 1 year ago

KaiHomeier commented 1 year ago

I wanted to have an unlabeled bar in the middle and solved it with hiding all labels that start with a '*'.

Example: Wages [1500] Budget Other [250] Budget

Budget [450] Taxes Budget [420] Housing Budget [400] Food Budget [295] Transportation Budget [25] Savings :Budget #708090 *Budget [160] Other Necessities #0F0

sankeymatic_20230518_095832_1200x1200

nowthis commented 1 year ago

Thanks for the PR.

I've been thinking about various ways to handle this for a while.. the final state I want to get to is that you ought to be able to set a custom display label (and other attributes) for a node in an actual data structure, like this:

Budget:
- label ""
- color slategrey
- value 1775
- ...etc.

...but some kind of shorthand you can apply in a flow declaration (as you have here) would also be great (and could be implemented much sooner, as a smaller project).

Along that line, where I'd like to go is to let people declare any kind of substitute label inline, not just turn it off.

I believe a workable syntax for that would be to let you prefix any node in a flow with "custom-label", and that string will be used as the display string for the node instead of the raw identifier. ("" could be used when you don't want any label shown, as in: "" Budget.)

You should only need to declare that extra label once, and SankeyMATIC should remember it. (And if another custom label is declared on a later line, that one should override the earlier one, following the common principle of "the last one wins".)

In your example, the syntax could look like this:

Wages [1500] Budget
Other [250] Budget

// the empty-string label could go on any of these lines, really:
"" Budget [450] Taxes
Budget [420] Housing
Budget [400] Food
...etc.

One reason I want this feature: In the "Ranked Election" example diagram, its display could be improved by taking out all the "Round 1/2/3" labels from the display (while leaving them in the raw data to keep the flow structure clear). The first few lines of that data could then look like this (with each unique node having a simpler label, declared once for each):

"GH" GH - Round 1 [300000] "GH" GH - Round 2
"EF" EF - Round 1 [220000] "EF" EF - Round 2
"CD" CD - Round 1 [200000] "CD" CD - Round 2
"AB" AB - Round 1 [10000] GH - Round 2
AB - Round 1 [25000] EF - Round 2
...etc.

But!

That said, here's a wrinkle in all of that:

In the not-very-distant future, you'll have the ability to turn on/off the display of all node Names and all Values separately. (See that new feature in progress at https://sankeymatic.com/build-next/ )

And in that new model, blanking out the Name will not automatically affect the display of the Value. In your example, setting the custom label of Budget to an empty string would still display the "1,750" amount by itself. Which you may or may not want.

I do think that having an easy way to turn off the entire label (Name, Value, maybe someday Percentage, Annotation...) will be useful on its own.

So I've been trying to work out what simple syntax would be good to indicate "I want to turn off the whole label for just this one Node", separately from the above custom-label feature idea.

A * prefix seems to me like something a person might believably want to display as part of a node name.

Perhaps if the node name starts and ends with something which wouldn't normally occur in a real name... Dashes at both ends, maybe, as in -Budget-? That visually reminds me of a strike-through, which I think may help mnemonically. Your example would become:

Wages [1500] -Budget-
Other [250] -Budget-

-Budget- [450] Taxes
...etc.

What do you think? If this syntax works for you, I can update the change to match that pattern instead of a *.

Thanks again.

KaiHomeier commented 1 year ago

Hi and thanks for all the explanation about this topic and what is planned with labels / values. I like the 'strike-through' syntax very much. I tested it and it works very well for me - I'll update the PR. I really like what you are doing here, btw. :-D

nowthis commented 1 year ago

Thanks. :) I will merge this soon.

KaiHomeier commented 1 year ago

hurray!