Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sankey diagrams #4502

Merged
merged 87 commits into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from 80 commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
4018fad
Ideas about sankey diagram syntax
nirname Jun 17, 2023
7f19e50
Desired sankey syntax
nirname Jun 17, 2023
116453d
Desired syntax sankey
nirname Jun 17, 2023
c2417de
Stated sankey backbone
nirname Jun 17, 2023
6b40b39
Picked state diagram as a sample for sankey
nirname Jun 17, 2023
8e001b9
Cleared sankey renderer
nirname Jun 17, 2023
fe3dd5a
Updated dockerfile
nirname Jun 17, 2023
c874d74
Some fixes to docker and demos
nirname Jun 17, 2023
ad95c99
Started sankey syntax
nirname Jun 17, 2023
567686e
Implementing new syntax
nirname Jun 17, 2023
d222660
Recognizing attrubutes
nirname Jun 17, 2023
b4b535f
Recognizing attributes
nirname Jun 17, 2023
f71769e
Attributes within strings
nirname Jun 17, 2023
5eae790
Sankey stream is ending on node only
nirname Jun 17, 2023
40f7105
Started renderer development
nirname Jun 17, 2023
1782f69
Increased mem for lint, fixed spell checking, run lint
nirname Jun 17, 2023
afaf87e
At last something is working
nirname Jun 17, 2023
8154214
Fix errors
nirname Jun 17, 2023
c41fc67
Added nodes and paths
nirname Jun 18, 2023
f5add81
Simple flow is done
nirname Jun 18, 2023
d22131e
It can read syntax and draw diagram
nirname Jun 18, 2023
19f858b
Fixed nodes duplicates
nirname Jun 18, 2023
9dbb987
Fix linters
nirname Jun 18, 2023
726efda
Fixed packaged
nirname Jun 18, 2023
6722ac7
Multiple improvements on syntax
nirname Jun 19, 2023
1009bb8
Prettify
nirname Jun 19, 2023
fd3ffdc
Prettify
nirname Jun 19, 2023
6077ba5
Updated syntax and fixed comments from review
nirname Jun 19, 2023
a2c055b
CSV syntax implementation
nirname Jun 20, 2023
362648b
Trim trailing spaces
nirname Jun 20, 2023
6c6efb2
Fix graph width
nirname Jun 20, 2023
24d9f59
Fix specs
nirname Jun 20, 2023
7bc5c19
Fix specs
nirname Jun 20, 2023
bc33c82
Merge branch 'develop' into feature/4492_sankey-diagrams
nirname Jun 21, 2023
272615e
Fixed tests and added node alignment
nirname Jun 21, 2023
be9cd48
Sankey syntax has beed reduced
nirname Jun 22, 2023
9a29066
Ensure that sankey keyword does not intefere with csv
nirname Jun 22, 2023
104aece
Cleanup sankey diagrams according code review
nirname Jun 22, 2023
518da32
Remove unnecessary parsing stage from render and prepare text before …
nirname Jun 22, 2023
d9036c7
Added gradient for sankey and cleaned code
nirname Jun 22, 2023
c75c106
Put styles back
nirname Jun 22, 2023
7ace602
Fixed linters
nirname Jun 22, 2023
73840ea
Decrease docker mem
nirname Jun 22, 2023
d766ac6
Prettier
nirname Jun 22, 2023
0a7d429
Fixes for docker local development
nirname Jun 24, 2023
2f281ba
Improvements for sankey diagram after review
nirname Jun 24, 2023
1674f12
Renamed sankey to sankey-beta
nirname Jun 24, 2023
b23e86a
Added options for coloring
nirname Jun 24, 2023
db2a556
Cleanup
nirname Jun 24, 2023
1d6074d
Sankey: Use [] instead of Array
nirname Jun 24, 2023
6a893a7
Styles are optional
nirname Jun 24, 2023
2a22bae
Update docs
nirname Jun 24, 2023
95ab598
Fix docs
nirname Jun 24, 2023
c5b89d1
Update docs
nirname Jun 24, 2023
a387333
Removed unnecessary configs and extra code
nirname Jun 25, 2023
b0825eb
Import at the top
nirname Jun 26, 2023
605e8d4
Sankey refactoring
nirname Jun 27, 2023
616c5e6
Move UID to separate file, refine run sh
nirname Jun 27, 2023
32c8524
Put d3-sankey under mermaid package
nirname Jun 27, 2023
830319e
Removed unnecessary TODO
nirname Jun 27, 2023
bbba643
Rmoved unnecessary imports in tests
nirname Jun 27, 2023
d4d7ce5
Fixed majority of ts errors for sankey
nirname Jun 27, 2023
0bbf055
Fix linters
nirname Jun 27, 2023
f0231ad
Lint
nirname Jun 27, 2023
e1c9aec
Merge remote-tracking branch 'nirname/develop' into feature/4492_sank…
nirname Jun 27, 2023
149cc44
Empty
nirname Jun 27, 2023
301073a
Update docs
nirname Jun 27, 2023
8b11176
Updates after review
nirname Jun 27, 2023
19bea10
Update docs
nirname Jun 27, 2023
a712e61
Loading avatars in parallel & started sankey documentation
nirname Jun 29, 2023
408c327
Contributors fetching failure must not hinder docs development
nirname Jun 29, 2023
8e3f8b1
Fixes after review
nirname Jun 29, 2023
95a4365
Let it be as it was in dev branch
nirname Jun 29, 2023
e7ad294
Merge branch 'develop' into feature/4492_sankey-diagrams
nirname Jun 29, 2023
e24dce1
Added sankey documentation
nirname Jun 29, 2023
9177350
Fixed double quotes, docs, demo and added more examples to run script
nirname Jun 29, 2023
06cb0c3
Fixed package json
nirname Jun 29, 2023
b2f6858
Prettier
nirname Jun 29, 2023
36df726
Update docs
nirname Jun 29, 2023
163a4b8
Trigger build in GA
nirname Jun 29, 2023
cd7fce4
Merge branch 'develop' into feature/4492_sankey-diagrams
nirname Jun 30, 2023
a627198
Docker+Cypress, better run, removed unused syntax
nirname Jul 1, 2023
084b765
Added tests for colors and fully setup cypress in Docker
nirname Jul 1, 2023
8ed2ee3
Sankey alignment tests
nirname Jul 1, 2023
abb7bb2
More detailed sankey docs
nirname Jul 1, 2023
c327ea9
Update docs
nirname Jul 1, 2023
afb979f
Merge branch 'develop' into feature/4492_sankey-diagrams
sidharthv96 Jul 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions __mocks__/sankeyRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* Mocked Sankey diagram renderer
*/

import { vi } from 'vitest';

export const draw = vi.fn().mockImplementation(() => {
return '';
});

export default {
draw,
};
1 change: 1 addition & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
"rehype",
"roledescription",
"sandboxed",
"sankey",
"setupgraphviewbox",
"shiki",
"sidharth",
Expand Down
14 changes: 14 additions & 0 deletions cypress/integration/rendering/sankey.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { imgSnapshotTest } from '../../helpers/util.js';

describe('Sankey Diagram', () => {
it('should render a simple example', () => {
imgSnapshotTest(
`
sankey-beta

a,b,10
`,
{}
);
});
});
3 changes: 3 additions & 0 deletions demos/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ <h2><a href="./timeline.html">Timeline</a></h2>
<li>
<h2><a href="./zenuml.html">ZenUML</a></h2>
</li>
<li>
<h2><a href="./sankey.html">Sankey</a></h2>
</li>
</ul>
</body>
</html>
139 changes: 139 additions & 0 deletions demos/sankey.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<title>States Mermaid Quick Test Page</title>
<link rel="icon" type="image/png" href="data:image/png;base64,iVBORw0KGgo=" />
<style>
div.mermaid {
/* font-family: 'trebuchet ms', verdana, arial; */
font-family: 'Courier New', Courier, monospace !important;
}
</style>
</head>

<body>
<h1>Sankey diagram demos</h1>
<h2>Energy flow</h2>
<pre class="mermaid">
sankey-beta

%% There are leading and trailing spaces, do not crop
Agricultural 'waste',Bio-conversion,124.729
%% line with a comment

%% Normal line
Bio-conversion,Liquid,0.597

%% Line with unquoted sankey keyword
sankey,target,10

%% Quoted sankey keyword
"sankey",target,10

%% Another normal line
Bio-conversion,Losses,26.862

%% Line with integer amount
Bio-conversion,Solid,280

%% Some blank lines in the middle of CSV


%% Another normal line
Bio-conversion,Gas,81.144

%% Quoted line
"Biofuel imports",Liquid,35

%% Quoted line with escaped quotes inside
"""Biomass imports""",Solid,35

%% Lines containing commas inside
%% Quoted and unquoted values should be equal in terms of graph
"District heating","Heating and cooling, commercial",22.505
District heating,"Heating and cooling, homes",46.184

%% A bunch of lines, normal CSV
Coal imports,Coal,11.606
Coal reserves,Coal,63.965
Coal,Solid,75.571
District heating,Industry,10.639
Electricity grid,Over generation / exports,104.453
Electricity grid,Heating and cooling - homes,113.726
Electricity grid,H2 conversion,27.14
Electricity grid,Industry,342.165
Electricity grid,Road transport,37.797
Electricity grid,Agriculture,4.412
Electricity grid,Heating and cooling - commercial,40.858
Electricity grid,Losses,56.691
Electricity grid,Rail transport,7.863
Electricity grid,Lighting & appliances - commercial,90.008
Electricity grid,Lighting & appliances - homes,93.494
Gas imports,Ngas,40.719
Gas reserves,Ngas,82.233
Gas,Heating and cooling - commercial,0.129
Gas,Losses,1.401
Gas,Thermal generation,151.891
Gas,Agriculture,2.096
Gas,Industry,48.58
Geothermal,Electricity grid,7.013
H2 conversion,H2,20.897
H2 conversion,Losses,6.242
H2,Road transport,20.897
Hydro,Electricity grid,6.995
Liquid,Industry,121.066
Liquid,International shipping,128.69
Liquid,Road transport,135.835
Liquid,Domestic aviation,14.458
Liquid,International aviation,206.267
Liquid,Agriculture,3.64
Liquid,National navigation,33.218
Liquid,Rail transport,4.413
Marine algae,Bio-conversion,4.375
Ngas,Gas,122.952
Nuclear,Thermal generation,839.978
Oil imports,Oil,504.287
Oil reserves,Oil,107.703
Oil,Liquid,611.99
Other waste,Solid,56.587
Other waste,Bio-conversion,77.81
Pumped heat,Heating and cooling - homes,193.026
Pumped heat,Heating and cooling - commercial,70.672
Solar PV,Electricity grid,59.901
Solar Thermal,Heating and cooling - homes,19.263
Solar,Solar Thermal,19.263
Solar,Solar PV,59.901
Solid,Agriculture,0.882
Solid,Thermal generation,400.12
Solid,Industry,46.477
Thermal generation,Electricity grid,525.531
Thermal generation,Losses,787.129
Thermal generation,District heating,79.329
Tidal,Electricity grid,9.452
UK land based bioenergy,Bio-conversion,182.01
"""Wave""",Electricity grid,19.013
"""Wind""",Electricity grid,289.366

%% lines at the end, do not remove


</pre>

<script type="module">
import mermaid from './mermaid.esm.mjs';
mermaid.initialize({
theme: 'default',
logLevel: 3,
securityLevel: 'loose',
sankey: {
title: 'Hey, this is Sankey-Beta',
width: 1200,
height: 600,
linkColor: 'gradient',
},
});
</script>
</body>
</html>
15 changes: 14 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
version: '3.9'
services:
mermaid:
image: node:20.3.1-alpine3.18
image: node:18.16.1-alpine3.18
stdin_open: true
tty: true
working_dir: /mermaid
mem_limit: '2G'
environment:
- NODE_OPTIONS=--max_old_space_size=2048
volumes:
- ./:/mermaid
- root_cache:/root/.cache
- root_local:/root/.local
- root_npm:/root/.npm
ports:
- 9000:9000
- 3333:3333
volumes:
root_cache:
root_local:
root_npm:
2 changes: 1 addition & 1 deletion docs/config/setup/modules/defaultConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#### Defined in

[defaultConfig.ts:2293](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L2293)
[defaultConfig.ts:2300](https://github.com/mermaid-js/mermaid/blob/master/packages/mermaid/src/defaultConfig.ts#L2300)

---

Expand Down
Loading
Loading