Skip to content

Commit 294ee6c

Browse files
committed
New Sample Diagrams: "Start Simple" and "Financial Results"
"Start Simple" gives you just 2 simple gray flows. - This is probably a better starting point when you're doing something which isn't like any of the other samples. "Financial Results" is an opinionated take on the quarterly-results graph of a business. Some notable things: - Costs and Expenses are distinct; color them differently. - Green/red is not an accessible color pairing. I took the cue for these particular colors from Bloomberg's accessible Terminal colors (https://www.bloomberg.com/ux/2021/10/14/designing-the-terminal-for-color-accessibility/): profit = blue, expense = rust, cost = a grayish variant of their default gold. "Financial Results", "Ranked Election", "Start Simple", and "Job Search" all now place their labels BEFORE their nodes. - This ought to make the diagrams easier to read for someone who hasn't seen a Sankey before. (Most people are not acclimated to reading & tracing labels when they switch positions in the middle.)
1 parent 054a69c commit 294ee6c

File tree

3 files changed

+77
-20
lines changed

3 files changed

+77
-20
lines changed

build/build.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,9 +373,9 @@ th#title {
373373
border: var(--border-base);
374374
border-style: dotted;
375375
border-radius: 0.7em;
376-
margin: 0.4em auto 1em;
377-
padding: 0.5em;
378-
box-shadow: 0.1em 0.1em 0.3em gray;
376+
margin: 0 auto 0.5em;
377+
padding: 0.2em;
378+
box-shadow: 0.1em 0.1em 0.2em gray;
379379
}
380380

381381
#example_diagrams h4 {

build/constants.js

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,17 @@ const fontMetrics
7777
name: 'Basic Budget',
7878
flows: "// Enter Flows between Nodes, like this:\n// Source [AMOUNT] Target\n\nWages [1500] Budget\nOther [250] Budget\n\nBudget [450] Taxes\nBudget [420] Housing\nBudget [400] Food\nBudget [295] Transportation\nBudget [25] Savings\n\n// You can set a Node's color, like this:\n:Budget #708090\n// ...or a color for a single Flow:\nBudget [160] Other Necessities #0F0\n\n// Use the controls below to customize\n// your diagram's appearance...",
7979
settings: {
80+
canvas_width: 600,
8081
node_height: 50,
8182
node_spacing: 85,
83+
node_width: 9,
8284
font_size: 16,
85+
unit_prefix: '',
8386
layout_style_auto: true,
8487
flow_outside_in: true,
88+
theme_a_radio: true,
89+
label_pos_inside: true,
90+
justify_ends: false,
8591
},
8692
}],
8793

@@ -90,11 +96,17 @@ const fontMetrics
9096
name: 'Ranked Election',
9197
flows: '// Sample Ranked Election diagram\n\nGH - Round 1 [300000] GH - Round 2\nEF - Round 1 [220000] EF - Round 2\nCD - Round 1 [200000] CD - Round 2\nAB - Round 1 [10000] GH - Round 2\nAB - Round 1 [25000] EF - Round 2\nAB - Round 1 [20000] CD - Round 2\n\nGH - Round 2 [310000] GH - Round 3\nEF - Round 2 [245000] EF - Round 3\nCD - Round 2 [50000] GH - Round 3\nCD - Round 2 [95000] EF - Round 3\n\n// This line sets a custom gray color:\n:No further votes #555 <<\nAB - Round 1 [20000] No further votes\nCD - Round 2 [75000] No further votes',
9298
settings: {
99+
canvas_width: 700,
93100
node_height: 76,
94101
node_spacing: 85,
95-
font_size: 13,
102+
node_width: 9,
103+
font_size: 14,
104+
unit_prefix: '',
96105
layout_style_exact: true,
97106
flow_inherit_from_source: true,
107+
theme_a_radio: true,
108+
label_pos_before: true,
109+
justify_ends: false,
98110
},
99111
}],
100112

@@ -103,11 +115,55 @@ const fontMetrics
103115
name: 'Job Search',
104116
flows: '// Sample Job Search diagram:\n\nApplications [4] Interview\nApplications [9] Rejected\nApplications [4] No Answer\n\nInterview [2] 2nd Interview\nInterview [2] No Offer\n\n2nd Interview [2] Offer\n\nOffer [1] Accepted\nOffer [1] Declined',
105117
settings: {
118+
canvas_width: 600,
106119
node_height: 50,
107120
node_spacing: 50,
121+
node_width: 5,
108122
font_size: 14,
123+
unit_prefix: '',
109124
layout_style_auto: true,
110125
flow_inherit_from_target: true,
126+
theme_a_radio: true,
127+
label_pos_before: true,
128+
justify_ends: false,
129+
},
130+
}],
131+
132+
// Sample quarterly financial results:
133+
['financial_results', {
134+
name: 'Financial Results',
135+
flows: 'Division A [900] Revenue\nDivision B [750] Revenue\nDivision C [150] Revenue\n\nRevenue [1000] Gross Profit\n\nGross Profit [350] Operating Profit\nGross Profit [650] Operating Expenses\n\nOperating Profit [260] Net Profit\nOperating Profit [90] Tax\n\nOperating Expenses [640] S G & Admin\nOperating Expenses [10] Amortization\n\nRevenue [800] Cost of Sales\n\n// Profit - blue\n:Gross Profit #48e <<\n:Operating Profit #48e <<\n:Net Profit #48e <<\n\n// Expenses - rust\n:Operating Expenses #d74 <<\n:Tax #d74 <<\n:S G & Admin #d74 <<\n:Amortization #d74 <<\n\n// Cost - grayish-gold\n:Cost of Sales #e6cc91 <<\n\n// main Revenue node: dark grey\n:Revenue #444',
136+
settings: {
137+
canvas_width: 800,
138+
node_height: 70,
139+
node_spacing: 70,
140+
node_width: 5,
141+
font_size: 13,
142+
unit_prefix: '$',
143+
layout_style_auto: true,
144+
node_use_color: true,
145+
flow_use_color: true,
146+
label_pos_before: true,
147+
justify_ends: true,
148+
},
149+
}],
150+
151+
// The most basic diagram:
152+
['simple_start', {
153+
name: 'Start Simple',
154+
flows: 'a [1] b\na [1] c',
155+
settings: {
156+
canvas_width: 600,
157+
node_height: 50,
158+
node_spacing: 80,
159+
node_width: 12,
160+
font_size: 15,
161+
unit_prefix: '',
162+
layout_style_auto: true,
163+
node_use_color: true,
164+
flow_use_color: true,
165+
label_pos_before: true,
166+
justify_ends: false,
111167
},
112168
}],
113169

build/index.html

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@
5757
<div class="center_basic">
5858

5959
<form id="skm_form" onsubmit="process_sankey(); return false;">
60+
<div id="example_diagrams" class="text_center">
61+
<h4>Sample Diagrams &amp; Starting Points:
62+
<button type="button" id="load_example_simple" onclick="replaceGraph('simple_start'); return false;">Start Simple</button>
63+
<button type="button" id="load_example_financial_results" onclick="replaceGraph('financial_results'); return false;">Financial Results</button>
64+
<button type="button" id="load_example_job_search" onclick="replaceGraph('job_search'); return false;">Job Search</button>
65+
<button type="button" id="load_example_election" onclick="replaceGraph('election'); return false;">Ranked Election</button>
66+
<!-- <button type="button" id="load_example_energy_all" onclick="replaceGraph('energy_flows_all'); return false;">Energy Flows</button> &nbsp; -->
67+
<button type="button" id="load_example_basic_budget" onclick="replaceGraph('default_budget'); return false;">Budget (Default)</button>
68+
</h4>
69+
70+
<p id="replace_graph_warning" style="display: none;">
71+
<em>This will <strong>erase</strong> your changes. Are you sure?</em><br />
72+
<input type="hidden" id="demo_graph_chosen" value="" />
73+
<button type="button" id="replace_graph_yes" onclick="replaceGraphConfirmed(); return false;">Yes, replace the diagram</button>
74+
<button type="button" id="replace_graph_no" onclick="hideReplaceGraphWarning(); return false;">Cancel</button>
75+
</p>
76+
</div>
6077

6178
<table><tr><td>
6279

@@ -405,22 +422,6 @@ <h3 class="ui_head" onclick="togglePanel('svg_options');"><span id="svg_options_
405422
</table>
406423

407424
</td><td id="grapharea">
408-
<div id="example_diagrams" class="text_center">
409-
<h4>Sample Diagrams:
410-
<button type="button" id="load_example_job_search" onclick="replaceGraph('job_search'); return false;">Job Search</button>
411-
<button type="button" id="load_example_election" onclick="replaceGraph('election'); return false;">Ranked Election</button>
412-
<!-- <button type="button" id="load_example_energy_all" onclick="replaceGraph('energy_flows_all'); return false;">Energy Flows</button> &nbsp; -->
413-
<button type="button" id="load_example_basic_budget" onclick="replaceGraph('default_budget'); return false;">Basic Budget (Default)</button>
414-
</h4>
415-
416-
<p id="replace_graph_warning" style="display: none;">
417-
<em>This will <strong>erase</strong> your changes. Are you sure?</em><br />
418-
<input type="hidden" id="demo_graph_chosen" value="" />
419-
<button type="button" id="replace_graph_yes" onclick="replaceGraphConfirmed(); return false;">Yes, replace the diagram</button>
420-
<button type="button" id="replace_graph_no" onclick="hideReplaceGraphWarning(); return false;">Cancel</button>
421-
</p>
422-
</div>
423-
424425
<!-- SIZE & SPACING & BACKGROUND -->
425426

426427
<div class="expandable_box">

0 commit comments

Comments
 (0)