1+ namespace Plotly.NET
2+
3+ /// Margin
4+ type Template () =
5+ inherit DynamicObj ()
6+
7+ /// Init Margin type
8+ static member init
9+ (
10+ layoutTemplate : Layout ,
11+ ? TraceTemplates : Trace []
12+ ) =
13+ Template()
14+ |> Template.style
15+ (
16+ layoutTemplate,
17+ ?TraceTemplates = TraceTemplates
18+ )
19+
20+ static member style
21+ (
22+ layoutTemplate : Layout ,
23+ ? TraceTemplates : Trace []
24+ ) =
25+ ( fun ( template : Template ) ->
26+ layoutTemplate |> DynObj.setValue template " layout"
27+ TraceTemplates |> DynObj.setValueOpt template " data"
28+
29+ template
30+ )
31+
32+ /// Applies the styles to Margin()
33+ static member mapLayoutTemplate ( styleF : Layout -> Layout ) ( template : Template ) =
34+ template.TryGetTypedValue< Layout>( " layout" )
35+ |> Option.map ( styleF)
36+ |> DynObj.setValueOpt template " layout"
37+ template
38+
39+ /// Applies the styles to Margin()
40+ static member mapTraceTemplates ( styleF : Trace [] -> Trace []) ( template : Template ) =
41+ template.TryGetTypedValue< Trace []>( " data" )
42+ |> Option.map ( styleF)
43+ |> DynObj.setValueOpt template " data"
44+ template
45+
46+ static member withColorWay ( colorway : string []) ( template : Template ) =
47+ template
48+ |> Template.mapLayoutTemplate ( fun l ->
49+ colorway |> DynObj.setValue l " colorway"
50+ l
51+ )
52+
53+ module ChartTemplates =
54+
55+ module ColorWays =
56+
57+ let plotly = [|
58+ " #636efa"
59+ " #EF553B"
60+ " #00cc96"
61+ " #ab63fa"
62+ " #FFA15A"
63+ " #19d3f3"
64+ " #FF6692"
65+ " #B6E880"
66+ " #FF97FF"
67+ " #FECB52"
68+ |]
69+
70+ let light =
71+
72+ let defaultFont = Font.init ( Size = 40 )
73+
74+ let defaultLayout =
75+ Layout.init (
76+ Paper_ bgcolor = " white" ,
77+ Plot_ bgcolor= " white" ,
78+ Font = defaultFont
79+ )
80+
81+
82+ Template.init( defaultLayout, TraceTemplates = [||])
83+
84+ let dark =
85+
86+ let initDarkAxisTemplate () =
87+ Axis.LinearAxis.init(
88+ Linecolor = " rgb(204, 204, 204)" ,
89+ Zerolinecolor = " rgb(204, 204, 204)" ,
90+ Gridcolor = " rgba(204, 204, 204, 0.3)" ,
91+ Tickcolor = " rgba(204, 204, 204, 0.5)" ,
92+ Showline= true ,
93+ Zeroline= true
94+ )
95+
96+ let darkLayoutTemplate =
97+ Layout.init(
98+ Paper_ bgcolor = " rgb(55, 55, 61)" ,
99+ Plot_ bgcolor= " rgb(55, 55, 61)" ,
100+ Font = Font.init( Color = " rgb(204, 204, 204)" )
101+ )
102+ |> Layout.AddLinearAxis(( StyleParam.AxisId.X 1 ),( initDarkAxisTemplate()))
103+ |> Layout.AddLinearAxis(( StyleParam.AxisId.Y 1 ),( initDarkAxisTemplate()))
104+
105+ Template.init( darkLayoutTemplate)
106+
107+ let darkMirrored =
108+ dark
109+ |> Template.mapLayoutTemplate ( fun l ->
110+ l.TryGetTypedValue< Axis.LinearAxis>( " xaxis" )
111+ |> Option.map ( Axis.LinearAxis.style ( Mirror= StyleParam.Mirror.AllTicks))
112+ |> DynObj.setValueOpt l " xaxis"
113+
114+ l.TryGetTypedValue< Axis.LinearAxis>( " yaxis" )
115+ |> Option.map ( Axis.LinearAxis.style ( Mirror= StyleParam.Mirror.AllTicks))
116+ |> DynObj.setValueOpt l " yaxis"
117+
118+ l
119+ )
0 commit comments