Skip to content

Commit 67f6720

Browse files
committed
Fix build errors and namespace issues
1 parent d2da2c5 commit 67f6720

File tree

7 files changed

+174
-176
lines changed

7 files changed

+174
-176
lines changed

src/Plotly.NET/Playground.fsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
#I "Templates"
124124

125125
#load "Template.fs"
126-
#load "PlotlyTheme.fs"
126+
#load "ChartTemplates.fs"
127127
#load "Defaults.fs"
128128

129129
#I "ChartAPI"
@@ -163,7 +163,7 @@ open FSharpAux
163163
open System
164164
open System.IO
165165

166-
Chart.Contour([[1;2];[3;4]])
166+
Chart.Line([1,2; 3,4])
167167
|> Chart.show
168168

169169
let layout =

src/Plotly.NET/Plotly.NET.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
<Compile Include="DisplayOptions\DisplayOptions.fs" />
120120
<Folder Include="Templates\ObjectAbstractions\" />
121121
<Compile Include="Templates\Template.fs" />
122-
<Compile Include="Templates\PlotlyTheme.fs" />
122+
<Compile Include="Templates\ChartTemplates.fs" />
123123
<Compile Include="Templates\Defaults.fs" />
124124
<Compile Include="ChartAPI\GenericChart.fs" />
125125
<Compile Include="ChartAPI\Chart.fs" />

src/Plotly.NET/Templates/PlotlyTheme.fs renamed to src/Plotly.NET/Templates/ChartTemplates.fs

Lines changed: 167 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,172 @@ open System.Runtime.InteropServices
99

1010
module ChartTemplates =
1111

12+
/// A colorway is an array of colors that contains the default colors for traces
13+
module ColorWays =
14+
15+
let plotly = Color.fromColors[|
16+
Color.fromHex "#636efa"
17+
Color.fromHex "#EF553B"
18+
Color.fromHex "#00cc96"
19+
Color.fromHex "#ab63fa"
20+
Color.fromHex "#FFA15A"
21+
Color.fromHex "#19d3f3"
22+
Color.fromHex "#FF6692"
23+
Color.fromHex "#B6E880"
24+
Color.fromHex "#FF97FF"
25+
Color.fromHex "#FECB52"
26+
|]
27+
28+
let fslab = Color.fromColors[|
29+
Color.fromHex "#A00975" // darkmagenta
30+
Color.fromHex "#D12F67" // rose
31+
Color.fromHex "#44d57f" // green
32+
Color.fromHex "#438AFE" // aquamarine
33+
Color.fromHex "#d59a1b" // dark yellow
34+
Color.fromHex "#F99BDE" // lightmagenta
35+
Color.fromHex "#ff9b9b" // light rose
36+
Color.fromHex "#c6ffdd" // light green
37+
Color.fromHex "#00d4ff" // light aquamarine
38+
Color.fromHex "#d2c572" // yellow
39+
|]
40+
41+
let light =
42+
let initLightAxisTemplate() =
43+
LinearAxis.init(
44+
ShowLine = true,
45+
ZeroLine = true
46+
)
47+
48+
let defaultLayout =
49+
Layout.init (
50+
PaperBGColor = Color.fromString "white",
51+
PlotBGColor = Color.fromString "white"
52+
)
53+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initLightAxisTemplate()))
54+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initLightAxisTemplate()))
55+
56+
Template.init(defaultLayout)
57+
58+
let lightMirrored =
59+
let initLightAxisTemplate() =
60+
LinearAxis.init(
61+
ShowLine = true,
62+
ZeroLine = true,
63+
Mirror = StyleParam.Mirror.All,
64+
Ticks = StyleParam.TickOptions.Inside
65+
//Showgrid = false
66+
)
67+
68+
let defaultLayout =
69+
Layout.init (
70+
PaperBGColor = Color.fromString "white",
71+
PlotBGColor = Color.fromString "white"
72+
)
73+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initLightAxisTemplate()))
74+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initLightAxisTemplate()))
75+
76+
Template.init(defaultLayout)
77+
78+
let dark =
79+
80+
let initDarkAxisTemplate() =
81+
LinearAxis.init(
82+
LineColor = Color.fromString "rgb(204, 204, 204)",
83+
ZeroLineColor = Color.fromString "rgb(204, 204, 204)",
84+
GridColor = Color.fromString "rgba(204, 204, 204, 0.3)",
85+
TickColor = Color.fromString"rgba(204, 204, 204, 0.5)",
86+
Ticks = StyleParam.TickOptions.Inside,
87+
ShowLine = true,
88+
ZeroLine = true
89+
)
90+
91+
let darkLayoutTemplate =
92+
Layout.init(
93+
PaperBGColor = Color.fromString "rgb(55, 55, 61)",
94+
PlotBGColor= Color.fromString "rgb(55, 55, 61)",
95+
Font = Font.init(Color = Color.fromString "rgb(204, 204, 204)")
96+
)
97+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initDarkAxisTemplate()))
98+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initDarkAxisTemplate()))
99+
100+
Template.init(darkLayoutTemplate)
101+
102+
let darkMirrored =
103+
dark
104+
|> Template.mapLayoutTemplate (fun l ->
105+
l.TryGetTypedValue<LinearAxis>("xaxis")
106+
|> Option.map (LinearAxis.style (Mirror=StyleParam.Mirror.AllTicks))
107+
|> DynObj.setValueOpt l "xaxis"
108+
109+
l.TryGetTypedValue<LinearAxis>("yaxis")
110+
|> Option.map (LinearAxis.style (Mirror=StyleParam.Mirror.AllTicks))
111+
|> DynObj.setValueOpt l "yaxis"
112+
113+
l
114+
)
115+
116+
let fslab =
117+
118+
let initFslabAxisTemplate() =
119+
LinearAxis.init(
120+
LineColor = Color.fromString "white",
121+
ZeroLineColor = Color.fromString"rgba(67, 138, 254, 0.5)",
122+
GridColor = Color.fromString "rgba(67, 138, 254, 0.5)",
123+
TickColor = Color.fromString "rgba(67, 138, 254, 0.5)",
124+
Ticks = StyleParam.TickOptions.Inside,
125+
ShowLine = true,
126+
ZeroLine = true
127+
)
128+
129+
let fslabLayoutTemplate =
130+
Layout.init(
131+
PaperBGColor = Color.fromString "#200117",
132+
PlotBGColor = Color.fromString "#200117",
133+
Font = Font.init(Color = Color.fromString "white")
134+
)
135+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initFslabAxisTemplate()))
136+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initFslabAxisTemplate()))
137+
138+
Template.init(fslabLayoutTemplate)
139+
|> Template.withColorWay ColorWays.fslab
140+
141+
142+
let transparent =
143+
let initTransparentAxisTemplate() =
144+
LinearAxis.init(
145+
ShowLine = true,
146+
ZeroLine = true
147+
)
148+
149+
let defaultLayout =
150+
Layout.init (
151+
PaperBGColor = Color.fromString "rgba(255, 255, 255, 0)",
152+
PlotBGColor = Color.fromString "rgba(255, 255, 255, 0)"
153+
)
154+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initTransparentAxisTemplate()))
155+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initTransparentAxisTemplate()))
156+
157+
Template.init(defaultLayout)
158+
159+
let transparentMirrored =
160+
let initTransparentAxisTemplate() =
161+
LinearAxis.init(
162+
ShowLine = true,
163+
ZeroLine = true,
164+
Mirror = StyleParam.Mirror.All,
165+
Ticks = StyleParam.TickOptions.Inside
166+
)
167+
168+
let defaultLayout =
169+
Layout.init (
170+
PaperBGColor = Color.fromString "rgba(255, 255, 255, 0)",
171+
PlotBGColor = Color.fromString "rgba(255, 255, 255, 0)"
172+
)
173+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initTransparentAxisTemplate()))
174+
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initTransparentAxisTemplate()))
175+
176+
Template.init(defaultLayout)
177+
12178
/// the default template, as used in the python lib by default.
13179
let plotly =
14180

@@ -454,4 +620,4 @@ module ChartTemplates =
454620
]
455621

456622
Template.init(layoutTempplate,traceTemplates)
457-
|> Template.withColorWay ChartTemplates.ColorWays.plotly
623+
|> Template.withColorWay ColorWays.plotly

src/Plotly.NET/Templates/Template.fs

Lines changed: 1 addition & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -80,172 +80,4 @@ type Template() =
8080
|> Template.mapLayoutTemplate (fun l ->
8181
colorway |> DynObj.setValue l "colorway"
8282
l
83-
)
84-
85-
module ChartTemplates =
86-
87-
/// A colorway is an array of colors that contains the default colors for traces
88-
module ColorWays =
89-
90-
let plotly = Color.fromColors[|
91-
Color.fromHex "#636efa"
92-
Color.fromHex "#EF553B"
93-
Color.fromHex "#00cc96"
94-
Color.fromHex "#ab63fa"
95-
Color.fromHex "#FFA15A"
96-
Color.fromHex "#19d3f3"
97-
Color.fromHex "#FF6692"
98-
Color.fromHex "#B6E880"
99-
Color.fromHex "#FF97FF"
100-
Color.fromHex "#FECB52"
101-
|]
102-
103-
let fslab = Color.fromColors[|
104-
Color.fromHex "#A00975" // darkmagenta
105-
Color.fromHex "#D12F67" // rose
106-
Color.fromHex "#44d57f" // green
107-
Color.fromHex "#438AFE" // aquamarine
108-
Color.fromHex "#d59a1b" // dark yellow
109-
Color.fromHex "#F99BDE" // lightmagenta
110-
Color.fromHex "#ff9b9b" // light rose
111-
Color.fromHex "#c6ffdd" // light green
112-
Color.fromHex "#00d4ff" // light aquamarine
113-
Color.fromHex "#d2c572" // yellow
114-
|]
115-
116-
let light =
117-
let initLightAxisTemplate() =
118-
LinearAxis.init(
119-
ShowLine = true,
120-
ZeroLine = true
121-
)
122-
123-
let defaultLayout =
124-
Layout.init (
125-
PaperBGColor = Color.fromString "white",
126-
PlotBGColor = Color.fromString "white"
127-
)
128-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initLightAxisTemplate()))
129-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initLightAxisTemplate()))
130-
131-
Template.init(defaultLayout)
132-
133-
let lightMirrored =
134-
let initLightAxisTemplate() =
135-
LinearAxis.init(
136-
ShowLine = true,
137-
ZeroLine = true,
138-
Mirror = StyleParam.Mirror.All,
139-
Ticks = StyleParam.TickOptions.Inside
140-
//Showgrid = false
141-
)
142-
143-
let defaultLayout =
144-
Layout.init (
145-
PaperBGColor = Color.fromString "white",
146-
PlotBGColor = Color.fromString "white"
147-
)
148-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initLightAxisTemplate()))
149-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initLightAxisTemplate()))
150-
151-
Template.init(defaultLayout)
152-
153-
let dark =
154-
155-
let initDarkAxisTemplate() =
156-
LinearAxis.init(
157-
LineColor = Color.fromString "rgb(204, 204, 204)",
158-
ZeroLineColor = Color.fromString "rgb(204, 204, 204)",
159-
GridColor = Color.fromString "rgba(204, 204, 204, 0.3)",
160-
TickColor = Color.fromString"rgba(204, 204, 204, 0.5)",
161-
Ticks = StyleParam.TickOptions.Inside,
162-
ShowLine = true,
163-
ZeroLine = true
164-
)
165-
166-
let darkLayoutTemplate =
167-
Layout.init(
168-
PaperBGColor = Color.fromString "rgb(55, 55, 61)",
169-
PlotBGColor= Color.fromString "rgb(55, 55, 61)",
170-
Font = Font.init(Color = Color.fromString "rgb(204, 204, 204)")
171-
)
172-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initDarkAxisTemplate()))
173-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initDarkAxisTemplate()))
174-
175-
Template.init(darkLayoutTemplate)
176-
177-
let darkMirrored =
178-
dark
179-
|> Template.mapLayoutTemplate (fun l ->
180-
l.TryGetTypedValue<LinearAxis>("xaxis")
181-
|> Option.map (LinearAxis.style (Mirror=StyleParam.Mirror.AllTicks))
182-
|> DynObj.setValueOpt l "xaxis"
183-
184-
l.TryGetTypedValue<LinearAxis>("yaxis")
185-
|> Option.map (LinearAxis.style (Mirror=StyleParam.Mirror.AllTicks))
186-
|> DynObj.setValueOpt l "yaxis"
187-
188-
l
189-
)
190-
191-
let fslab =
192-
193-
let initFslabAxisTemplate() =
194-
LinearAxis.init(
195-
LineColor = Color.fromString "white",
196-
ZeroLineColor = Color.fromString"rgba(67, 138, 254, 0.5)",
197-
GridColor = Color.fromString "rgba(67, 138, 254, 0.5)",
198-
TickColor = Color.fromString "rgba(67, 138, 254, 0.5)",
199-
Ticks = StyleParam.TickOptions.Inside,
200-
ShowLine = true,
201-
ZeroLine = true
202-
)
203-
204-
let fslabLayoutTemplate =
205-
Layout.init(
206-
PaperBGColor = Color.fromString "#200117",
207-
PlotBGColor = Color.fromString "#200117",
208-
Font = Font.init(Color = Color.fromString "white")
209-
)
210-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initFslabAxisTemplate()))
211-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initFslabAxisTemplate()))
212-
213-
Template.init(fslabLayoutTemplate)
214-
|> Template.withColorWay ColorWays.fslab
215-
216-
217-
let transparent =
218-
let initTransparentAxisTemplate() =
219-
LinearAxis.init(
220-
ShowLine = true,
221-
ZeroLine = true
222-
)
223-
224-
let defaultLayout =
225-
Layout.init (
226-
PaperBGColor = Color.fromString "rgba(255, 255, 255, 0)",
227-
PlotBGColor = Color.fromString "rgba(255, 255, 255, 0)"
228-
)
229-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initTransparentAxisTemplate()))
230-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initTransparentAxisTemplate()))
231-
232-
Template.init(defaultLayout)
233-
234-
let transparentMirrored =
235-
let initTransparentAxisTemplate() =
236-
LinearAxis.init(
237-
ShowLine = true,
238-
ZeroLine = true,
239-
Mirror = StyleParam.Mirror.All,
240-
Ticks = StyleParam.TickOptions.Inside
241-
)
242-
243-
let defaultLayout =
244-
Layout.init (
245-
PaperBGColor = Color.fromString "rgba(255, 255, 255, 0)",
246-
PlotBGColor = Color.fromString "rgba(255, 255, 255, 0)"
247-
)
248-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.XAxis 1),(initTransparentAxisTemplate()))
249-
|> Layout.AddLinearAxis((StyleParam.SubPlotId.YAxis 1),(initTransparentAxisTemplate()))
250-
251-
Template.init(defaultLayout)
83+
)

tests/Plotly.NET.Tests.CSharpConsole/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ static void Main(string[] args)
3434
trace.SetValue("name", "Hello from C#");
3535

3636
GenericChart
37-
.ofTraceObject(trace)
37+
.ofTraceObject(true,trace)
3838
.WithLayout(layout)
3939
.Show();
4040
}

0 commit comments

Comments
 (0)