-
Notifications
You must be signed in to change notification settings - Fork 81
/
09_2_sankey.fsx
81 lines (69 loc) · 2.33 KB
/
09_2_sankey.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(**
---
title: Sankey Charts
category: Categorical Charts
categoryindex: 10
index: 3
---
*)
(*** hide ***)
(*** condition: prepare ***)
#r "nuget: Newtonsoft.JSON, 13.0.1"
#r "nuget: DynamicObj, 2.0.0"
#r "nuget: Giraffe.ViewEngine, 1.4.0"
#r "../src/Plotly.NET/bin/Release/netstandard2.0/Plotly.NET.dll"
Plotly.NET.Defaults.DefaultDisplayOptions <-
Plotly.NET.DisplayOptions.init (PlotlyJSReference = Plotly.NET.PlotlyJSReference.NoReference)
(*** condition: ipynb ***)
#if IPYNB
#r "nuget: Plotly.NET, {{fsdocs-package-version}}"
#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}"
#endif // IPYNB
(**
# Sankey charts
[![Binder]({{root}}img/badge-binder.svg)](https://mybinder.org/v2/gh/plotly/plotly.net/gh-pages?urlpath=/tree/home/jovyan/{{fsdocs-source-basename}}.ipynb) 
[![Notebook]({{root}}img/badge-notebook.svg)]({{root}}{{fsdocs-source-basename}}.ipynb)
*Summary:* This example shows how to create sankey charts in F#.
Sankey charts are a visualization of multiple, linked graphs layed out linearly.
These are usually used to depict flow between nodes or stations.
To create Sankey, a set of nodes and links between them are required.
These are created using the provided Node and Link structures.
*)
open Plotly.NET
let sankey1 =
Chart.Sankey(
nodeLabels = [ "A1"; "A2"; "B1"; "B2"; "C1"; "C2"; "D1" ],
linkedNodeIds =
[ // Edgelist, toupling sourceIndex => targetIndex of the link
0, 2
0, 3
1, 3
2, 4
3, 4
3, 5
4, 6
5, 6 ],
NodeOutlineColor = Color.fromKeyword Black,
NodeOutlineWidth = 1.,
linkValues = [ 8; 4; 2; 7; 3; 2; 5; 2 ],
LinkColor =
Color.fromColors
[ Color.fromHex "#828BFB"
Color.fromHex "#828BFB"
Color.fromHex "#F27762"
Color.fromHex "#33D6AB"
Color.fromHex "#BC82FB"
Color.fromHex "#BC82FB"
Color.fromHex "#FFB47B"
Color.fromHex "#47DCF5" ],
LinkOutlineColor = Color.fromKeyword Black,
LinkOutlineWidth = 1.,
UseDefaults = false
)
(*** condition: ipynb ***)
#if IPYNB
sankey1
#endif // IPYNB
(***hide***)
sankey1 |> GenericChart.toChartHTML
(***include-it-raw***)