1+ module ChartDomainTestCharts
2+
3+ open Plotly.NET
4+
5+
6+ module Pie =
7+
8+ let ``Simple pie chart`` =
9+ let values = [ 19 ; 26 ; 55 ;]
10+ let labels = [ " Residential" ; " Non-Residential" ; " Utility" ]
11+ Chart.Pie( values = values, Labels = labels, UseDefaults = false )
12+
13+ let ``Styled pie chart`` =
14+
15+ let values = [ 19 ; 26 ; 55 ;]
16+ let labels = [ " Residential" ; " Non-Residential" ; " Utility" ]
17+
18+ Chart.Pie(
19+ values = values,
20+ Labels = labels,
21+ SectionColors = [
22+ Color.fromKeyword Aqua
23+ Color.fromKeyword Salmon
24+ Color.fromKeyword Tan
25+ ],
26+ SectionOutlineColor = Color.fromKeyword Black,
27+ SectionOutlineWidth = 2. ,
28+ MultiText = [
29+ " Some"
30+ " More"
31+ " Stuff"
32+ ],
33+ MultiTextPosition = [
34+ StyleParam.TextPosition.Inside
35+ StyleParam.TextPosition.Outside
36+ StyleParam.TextPosition.Inside
37+ ],
38+ Rotation = 45. ,
39+ MultiPull = [ 0. ; 0.3 ; 0. ],
40+ UseDefaults = false
41+ )
42+
43+ module Doughnut =
44+
45+ let ``Simple doughnut chart`` =
46+ let values = [ 19 ; 26 ; 55 ;]
47+ let labels = [ " Residential" ; " Non-Residential" ; " Utility" ]
48+ Chart.Doughnut(
49+ values = values,
50+ Labels = labels,
51+ Hole= 0.3 ,
52+ MultiText= labels,
53+ UseDefaults = false
54+ )
55+
56+ module FunnelArea = ()
57+
58+ module Sunburst = ()
59+
60+ module Treemap = ()
61+
62+ module ParralelCoord = ()
63+
64+ module ParralelCategories = ()
65+
66+ module Sankey = ()
67+
68+ module Table =
69+
70+ let ``Simple table chart`` =
71+ let header = [ " <b>RowIndex</b>" ; " A" ; " simple" ; " table" ]
72+ let rows =
73+ [
74+ [ " 0" ; " I" ; " am" ; " a" ]
75+ [ " 1" ; " little" ; " example" ; " !" ]
76+ ]
77+ Chart.Table( headerValues = header, cellsValues = rows, UseDefaults = false )
78+
79+ let ``Styled table chart`` =
80+ let header = [ " <b>RowIndex</b>" ; " A" ; " simple" ; " table" ]
81+ let rows =
82+ [
83+ [ " 0" ; " I" ; " am" ; " a" ]
84+ [ " 1" ; " little" ; " example" ; " !" ]
85+ ]
86+ Chart.Table(
87+ headerValues = header,
88+ cellsValues = rows,
89+ HeaderAlign = StyleParam.HorizontalAlign.Center,
90+ CellsMultiAlign = [ StyleParam.HorizontalAlign.Left; StyleParam.HorizontalAlign.Center; StyleParam.HorizontalAlign.Right],
91+ HeaderFillColor = Color.fromString " #45546a" ,
92+ CellsFillColor = Color.fromColors [ Color.fromString " #deebf7" ; Color.fromString " lightgrey" ; Color.fromString " #deebf7" ; Color.fromString " lightgrey" ],
93+ HeaderHeight = 30 ,
94+ HeaderOutlineColor = Color.fromString " black" ,
95+ HeaderOutlineWidth = 2. ,
96+ MultiColumnWidth = [ 70. ; 50. ; 100. ; 70. ],
97+ ColumnOrder = [ 1 ; 2 ; 3 ; 4 ],
98+ UseDefaults = false
99+ )
100+
101+ let ``Cell color dependent table chart`` =
102+ let header2 = [ " Identifier" ; " T0" ; " T1" ; " T2" ; " T3" ]
103+ let rowvalues =
104+ [
105+ [ 10001. ; 0.2 ; 2.0 ; 4.0 ; 5.0 ]
106+ [ 10002. ; 2.1 ; 2.0 ; 1.8 ; 2.1 ]
107+ [ 10003. ; 4.5 ; 3.0 ; 2.0 ; 2.5 ]
108+ [ 10004. ; 0.0 ; 0.1 ; 0.3 ; 0.2 ]
109+ [ 10005. ; 1.0 ; 1.6 ; 1.8 ; 2.2 ]
110+ [ 10006. ; 1.0 ; 0.8 ; 1.5 ; 0.7 ]
111+ [ 10007. ; 2.0 ; 2.0 ; 2.1 ; 1.9 ]
112+ ]
113+ |> Seq.sortBy ( fun x -> x.[ 1 ])
114+
115+ //map color from value to hex representation
116+ let mapColor min max value =
117+ let proportion =
118+ ( 255. * ( value - min) / ( max - min))
119+ |> int
120+ Color.fromRGB 255 ( 255 - proportion) proportion
121+
122+ //Assign a color to every cell seperately. Matrix must be transposed for correct orientation.
123+ let cellcolor =
124+ rowvalues
125+ |> Seq.map ( fun row ->
126+ row
127+ |> Seq.mapi ( fun index value ->
128+ if index = 0 then Color.fromString " white"
129+ else mapColor 0. 5. value
130+ )
131+ )
132+ |> Seq.transpose
133+ |> Seq.map Color.fromColors
134+ |> Color.fromColors
135+
136+ Chart.Table(
137+ headerValues = header2,
138+ cellsValues = rowvalues,
139+ CellsFillColor= cellcolor,
140+ UseDefaults = false
141+ )
142+
143+
144+ let ``Sequence representation table chart`` =
145+ let sequence =
146+ [
147+ " ATGAGACGTCGAGACTGATAGACGTCGATAGACGTCGATAGACCG"
148+ " ATAGACTCGTGATAGACGTCGATAGACGTCGATAGAGTATAGACC"
149+ " GTGATAGACGTCGAGAAGACGTCGATAGACGTCGATAGACGTCGA"
150+ " TAGAGATAGACGTCGATAGACCGTATAGAAGACGTCGATAGATAG"
151+ " ACGTCGATAGACCGTAGACGTCGATAGACGTCGATAGACCGT"
152+ ]
153+ |> String.concat " "
154+
155+ let elementsPerRow = 60
156+
157+ let headers =
158+ [ 0 .. elementsPerRow]
159+ |> Seq.map ( fun x ->
160+ if x% 10 = 0 && x <> 0 then " |"
161+ else " "
162+ )
163+
164+ let cells =
165+ sequence
166+ |> Seq.chunkBySize elementsPerRow
167+ |> Seq.mapi ( fun i x -> Seq.append [ string ( i * elementsPerRow)] ( Seq.map string x))
168+
169+ let cellcolors =
170+ cells
171+ |> Seq.map ( fun row ->
172+ row
173+ |> Seq.map ( fun element ->
174+ match element with
175+ //colors taken from DRuMS
176+ //(http://biomodel.uah.es/en/model4/dna/atgc.htm)
177+ | " A" -> Color.fromString " #5050FF"
178+ | " T" -> Color.fromString " #E6E600"
179+ | " G" -> Color.fromString " #00C000"
180+ | " C" -> Color.fromString " #E00000"
181+ | " U" -> Color.fromString " #B48100"
182+ | _ -> Color.fromString " white"
183+ )
184+ )
185+ |> Seq.transpose
186+ |> Seq.map ( fun x -> Seq.append x ( seq [ Color.fromString " white" ]))
187+ |> Seq.map Color.fromColors
188+ |> Color.fromColors
189+
190+ let line = Line.init( Width = 0. , Color = Color.fromString " white" )
191+ let chartwidth = 50 + 10 * elementsPerRow
192+
193+ Chart.Table(
194+ headerValues = headers,
195+ cellsValues = cells,
196+ CellsOutline = line,
197+ HeaderOutline = line,
198+ CellsHeight = 20 ,
199+ MultiColumnWidth = [ 50. ; 10. ],
200+ CellsMultiAlign = [ StyleParam.HorizontalAlign.Right; StyleParam.HorizontalAlign.Center],
201+ CellsFillColor = cellcolors,
202+ UseDefaults = false
203+ )
204+ |> Chart.withSize( Width= chartwidth)
205+ |> Chart.withTitle " Sequence A"
206+
207+ module Indicator = ()
208+
209+ module Icicle = ()
0 commit comments