-
Notifications
You must be signed in to change notification settings - Fork 0
/
HnCTemplate.fsx
170 lines (157 loc) · 5.92 KB
/
HnCTemplate.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#r "nuget: Feliz.ViewEngine, 0.24.0"
#r "nuget: Plotly.NET, 4.2.0"
open Feliz.ViewEngine
open System
open System.Diagnostics
open System.IO
open Plotly.NET
open Plotly.NET.LayoutObjects
module Light =
let private colorway =
Color.fromColors
[|
Color.fromHex "#6929C4"
Color.fromHex "#1192E8"
Color.fromHex "#005D5D"
Color.fromHex "#9F1853"
Color.fromHex "#EE5396"
Color.fromHex "#002D9C"
Color.fromHex "#520408"
Color.fromHex "#198038"
Color.fromHex "#FA4D56"
Color.fromHex "#B28600"
Color.fromHex "#009D9A"
Color.fromHex "#001141"
Color.fromHex "#8A3800"
Color.fromHex "#A56EFF"
|]
let private axisTemplate =
LinearAxis.init (
LineColor = Color.fromHex "#8D8D8D",
GridColor = Color.fromString "#E0E0E0",
Ticks = StyleParam.TickOptions.Empty,
ShowLine = true,
ZeroLine = false,
Title = Title.init(Standoff = 8),
TickFont = Font.init(
Family = StyleParam.FontFamily.Custom "IBM Plex Sans SemiBold,Times New Roman,Helvetica Neue,Arial,sans-serif",
Size = 12.0,
Color = Color.fromHex "#525252"
)
)
let hncTemplate =
Layout.init (
Colorway = colorway,
PaperBGColor = Color.fromHex "#FFFFFF",
PlotBGColor = Color.fromHex "#FFFFFF",
Font = Font.init(
Family = StyleParam.FontFamily.Custom "IBM Plex Sans Regular,Times New Roman,Helvetica Neue,Arial,sans-serif",
Size = 12.0,
Color = Color.fromHex "#161616"
),
Title = Title.init(
Font = Font.init(
Family = StyleParam.FontFamily.Custom "IBM Plex Sans SemiBold,Times New Roman,Helvetica Neue,Arial,sans-serif",
Size = 16.0,
Color = Color.fromHex "#161616"
),
X = 0.05
),
Legend = Legend.init(
Font = Font.init(
Family = StyleParam.FontFamily.Custom "IBM Plex Sans Regular,Times New Roman,Helvetica Neue,Arial,sans-serif",
Size = 12.0,
Color = Color.fromHex "#525252"
)
//Orientation = StyleParam.Orientation.Horizontal,
//XAnchor = StyleParam.XAnchorPosition.Center,
//YAnchor = StyleParam.YAnchorPosition.Bottom,
//Y = 1.0,
//X = 0.5
)
)
|> Layout.setLinearAxis ((StyleParam.SubPlotId.XAxis 1), axisTemplate)
|> Layout.setLinearAxis ((StyleParam.SubPlotId.YAxis 1), axisTemplate)
|> Template.init
module Dark =
let private colorway =
Color.fromColors
[|
Color.fromHex "#8A3FFC"
Color.fromHex "#08BDBA"
Color.fromHex "#BAE6FF"
Color.fromHex "#33B1FF"
Color.fromHex "#007D79"
Color.fromHex "#6FDC8C"
Color.fromHex "#4589FF"
Color.fromHex "#D4BBFF"
Color.fromHex "#FFF1F1"
Color.fromHex "#FF7EB6"
Color.fromHex "#D02670"
Color.fromHex "#FA4D56"
Color.fromHex "#BA4E00"
Color.fromHex "#D2A106"
|]
let private axisTemplate =
LinearAxis.init (
LineColor = Color.fromHex "#8D8D8D",
GridColor = Color.fromString "#393939",
Ticks = StyleParam.TickOptions.Empty,
ShowLine = true,
ZeroLine = false,
Title = Title.init(Standoff = 8),
TickFont = Font.init(
Family = StyleParam.FontFamily.Custom "IBM Plex Sans SemiBold,Times New Roman,Helvetica Neue,Arial,sans-serif",
Size = 12.0,
Color = Color.fromHex "#525252"
)
)
let hncTemplate =
Layout.init (
Colorway = colorway,
PaperBGColor = Color.fromHex "#001141",
PlotBGColor = Color.fromHex "#001141",
Font = Font.init(
Family = StyleParam.FontFamily.Custom "IBM Plex Sans Regular,Times New Roman,Helvetica Neue,Arial,sans-serif",
Size = 12.0,
Color = Color.fromHex "#F4F4F4"
),
Title = Title.init(
Font = Font.init(
Family = StyleParam.FontFamily.Custom "IBM Plex Sans SemiBold,Times New Roman,Helvetica Neue,Arial,sans-serif",
Size = 16.0,
Color = Color.fromHex "#F4F4F4"
),
X = 0.05
),
Legend = Legend.init(
Font = Font.init(
Family = StyleParam.FontFamily.Custom "IBM Plex Sans Regular,Times New Roman,Helvetica Neue,Arial,sans-serif",
Size = 12.0,
Color = Color.fromHex "#525252"
)
//Orientation = StyleParam.Orientation.Horizontal,
//XAnchor = StyleParam.XAnchorPosition.Center,
//YAnchor = StyleParam.YAnchorPosition.Bottom,
//Y = 1.0,
//X = 0.5
)
)
|> Layout.setLinearAxis ((StyleParam.SubPlotId.XAxis 1), axisTemplate)
|> Layout.setLinearAxis ((StyleParam.SubPlotId.YAxis 1), axisTemplate)
|> Template.init
let displayCharts (charts: GenericChart.GenericChart seq) =
let build charts =
Html.html [
Html.head [ Html.title "Charts" ]
Html.body [
for c in (charts|> Seq.rev) do
prop.dangerouslySetInnerHTML (c |> Chart.withTemplate Light.hncTemplate |> GenericChart.toEmbeddedHTML)
]
]
let document = Render.htmlDocument (build charts)
let fileName = sprintf "%s%s%s" (Path.GetTempPath()) (Guid.NewGuid().ToString()) ".html"
File.WriteAllText(fileName, document)
let psi = new ProcessStartInfo(UseShellExecute = true, FileName = fileName)
let p = new Process(StartInfo = psi)
p.Start()