@@ -11,16 +11,13 @@ open System.Runtime.CompilerServices
11
11
/// Extensions methods from Plotly.NET.ImageExport for the Chart module, supporting the fluent pipeline style
12
12
[<AutoOpen>]
13
13
module ChartExtensions =
14
-
15
- type internal RenderOptions
16
- (
17
- ?EngineType: ExportEngine,
18
- ?Width : int,
19
- ?Height : int
20
- ) =
21
- member _.Engine = ( defaultArg EngineType ExportEngine.PuppeteerSharp) |> ExportEngine.getEngine
22
- member _.Width = defaultArg Width 600
23
- member _.Height = defaultArg Height 600
14
+
15
+ type internal RenderOptions (? EngineType : ExportEngine , ? Width : int , ? Height : int ) =
16
+ member _.Engine =
17
+ ( defaultArg EngineType ExportEngine.PuppeteerSharp) |> ExportEngine.getEngine
18
+
19
+ member _.Width = defaultArg Width 600
20
+ member _.Height = defaultArg Height 600
24
21
25
22
type Chart with
26
23
@@ -33,15 +30,16 @@ module ChartExtensions =
33
30
[<CompiledName( " ToBase64JPGStringAsync" ) >]
34
31
static member toBase64JPGStringAsync
35
32
(
36
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
37
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
38
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
39
- ) =
40
-
41
- let opts = RenderOptions( ?EngineType= EngineType, ?Width= Width, ?Height= Height)
42
-
43
- fun ( gChart : GenericChart ) -> opts.Engine.RenderJPGAsync( opts.Width, opts.Height, gChart)
44
-
33
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
34
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
35
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
36
+ ) =
37
+
38
+ let opts =
39
+ RenderOptions( ?EngineType = EngineType, ?Width = Width, ?Height = Height)
40
+
41
+ fun ( gChart : GenericChart ) -> opts.Engine.RenderJPGAsync( opts.Width, opts.Height, gChart)
42
+
45
43
/// <summary>
46
44
/// Returns a function that converts a GenericChart to a base64 encoded JPG string
47
45
/// </summary>
@@ -51,14 +49,14 @@ module ChartExtensions =
51
49
[<CompiledName( " ToBase64JPGString" ) >]
52
50
static member toBase64JPGString
53
51
(
54
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
55
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
56
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
57
- ) =
58
- fun ( gChart : GenericChart ) ->
59
- gChart
60
- |> Chart.toBase64JPGStringAsync( ?EngineType= EngineType, ?Width= Width, ?Height= Height)
61
- |> Async.RunSynchronously
52
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
53
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
54
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
55
+ ) =
56
+ fun ( gChart : GenericChart) ->
57
+ gChart
58
+ |> Chart.toBase64JPGStringAsync ( ?EngineType = EngineType, ?Width = Width, ?Height = Height)
59
+ |> Async.RunSynchronously
62
60
63
61
/// <summary>
64
62
/// Returns an async function that saves a GenericChart as JPG image
@@ -68,17 +66,18 @@ module ChartExtensions =
68
66
/// <param name="Width">width of the resulting image</param>
69
67
/// <param name="Height">height of the resulting image</param>
70
68
[<CompiledName( " SaveJPGAsync" ) >]
71
- static member saveJPGAsync
69
+ static member saveJPGAsync
72
70
(
73
71
path : string ,
74
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
75
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
76
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
77
- ) =
72
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
73
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
74
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
75
+ ) =
76
+
77
+ let opts =
78
+ RenderOptions( ?EngineType = EngineType, ?Width = Width, ?Height = Height)
78
79
79
- let opts = RenderOptions( ?EngineType= EngineType, ?Width= Width, ?Height= Height)
80
-
81
- fun ( gChart : GenericChart ) -> opts.Engine.SaveJPGAsync( path, opts.Width, opts.Height, gChart)
80
+ fun ( gChart : GenericChart ) -> opts.Engine.SaveJPGAsync( path, opts.Width, opts.Height, gChart)
82
81
83
82
/// <summary>
84
83
/// Returns a function that saves a GenericChart as JPG image
@@ -91,14 +90,14 @@ module ChartExtensions =
91
90
static member saveJPG
92
91
(
93
92
path : string ,
94
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
95
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
96
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
97
- ) =
98
- fun ( gChart : GenericChart ) ->
99
- gChart
100
- |> Chart.saveJPGAsync( path, ?EngineType= EngineType, ?Width= Width, ?Height= Height)
101
- |> Async.RunSynchronously
93
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
94
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
95
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
96
+ ) =
97
+ fun ( gChart : GenericChart) ->
98
+ gChart
99
+ |> Chart.saveJPGAsync ( path, ?EngineType = EngineType, ?Width = Width, ?Height = Height)
100
+ |> Async.RunSynchronously
102
101
103
102
/// <summary>
104
103
/// Returns an async function that converts a GenericChart to a base64 encoded PNG string
@@ -109,14 +108,15 @@ module ChartExtensions =
109
108
[<CompiledName( " ToBase64PNGStringAsync" ) >]
110
109
static member toBase64PNGStringAsync
111
110
(
112
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
113
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
114
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
115
- ) =
116
-
117
- let opts = RenderOptions( ?EngineType= EngineType, ?Width= Width, ?Height= Height)
118
-
119
- fun ( gChart : GenericChart ) -> opts.Engine.RenderPNGAsync( opts.Width, opts.Height, gChart)
111
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
112
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
113
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
114
+ ) =
115
+
116
+ let opts =
117
+ RenderOptions( ?EngineType = EngineType, ?Width = Width, ?Height = Height)
118
+
119
+ fun ( gChart : GenericChart ) -> opts.Engine.RenderPNGAsync( opts.Width, opts.Height, gChart)
120
120
121
121
/// <summary>
122
122
/// Returns a function that converts a GenericChart to a base64 encoded PNG string
@@ -127,14 +127,14 @@ module ChartExtensions =
127
127
[<CompiledName( " ToBase64PNGString" ) >]
128
128
static member toBase64PNGString
129
129
(
130
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
131
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
132
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
133
- ) =
134
- fun ( gChart : GenericChart ) ->
135
- gChart
136
- |> Chart.toBase64PNGStringAsync( ?EngineType= EngineType, ?Width= Width, ?Height= Height)
137
- |> Async.RunSynchronously
130
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
131
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
132
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
133
+ ) =
134
+ fun ( gChart : GenericChart) ->
135
+ gChart
136
+ |> Chart.toBase64PNGStringAsync ( ?EngineType = EngineType, ?Width = Width, ?Height = Height)
137
+ |> Async.RunSynchronously
138
138
139
139
/// <summary>
140
140
/// Returns an async function that saves a GenericChart as PNG image
@@ -147,13 +147,14 @@ module ChartExtensions =
147
147
static member savePNGAsync
148
148
(
149
149
path : string ,
150
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
151
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
152
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
153
- ) =
154
- let opts = RenderOptions( ?EngineType= EngineType, ?Width= Width, ?Height= Height)
155
-
156
- fun ( gChart : GenericChart ) -> opts.Engine.SavePNGAsync( path, opts.Width, opts.Height, gChart)
150
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
151
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
152
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
153
+ ) =
154
+ let opts =
155
+ RenderOptions( ?EngineType = EngineType, ?Width = Width, ?Height = Height)
156
+
157
+ fun ( gChart : GenericChart ) -> opts.Engine.SavePNGAsync( path, opts.Width, opts.Height, gChart)
157
158
158
159
159
160
/// <summary>
@@ -167,15 +168,15 @@ module ChartExtensions =
167
168
static member savePNG
168
169
(
169
170
path : string ,
170
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
171
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
172
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
173
- ) =
174
- fun ( gChart : GenericChart ) ->
175
- gChart
176
- |> Chart.savePNGAsync( path, ?EngineType= EngineType, ?Width= Width, ?Height= Height)
177
- |> Async.RunSynchronously
178
-
171
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
172
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
173
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
174
+ ) =
175
+ fun ( gChart : GenericChart) ->
176
+ gChart
177
+ |> Chart.savePNGAsync ( path, ?EngineType = EngineType, ?Width = Width, ?Height = Height)
178
+ |> Async.RunSynchronously
179
+
179
180
/// <summary>
180
181
/// Returns an async function that converts a GenericChart to a SVG string
181
182
/// </summary>
@@ -185,13 +186,14 @@ module ChartExtensions =
185
186
[<CompiledName( " ToSVGStringAsync" ) >]
186
187
static member toSVGStringAsync
187
188
(
188
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
189
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
190
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
191
- ) =
192
- let opts = RenderOptions( ?EngineType= EngineType, ?Width= Width, ?Height= Height)
193
-
194
- fun ( gChart : GenericChart ) -> opts.Engine.RenderSVGAsync( opts.Width, opts.Height, gChart)
189
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
190
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
191
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
192
+ ) =
193
+ let opts =
194
+ RenderOptions( ?EngineType = EngineType, ?Width = Width, ?Height = Height)
195
+
196
+ fun ( gChart : GenericChart ) -> opts.Engine.RenderSVGAsync( opts.Width, opts.Height, gChart)
195
197
196
198
/// <summary>
197
199
/// Returns a function that converts a GenericChart to a SVG string
@@ -200,17 +202,17 @@ module ChartExtensions =
200
202
/// <param name="Width">width of the resulting image</param>
201
203
/// <param name="Height">height of the resulting image</param>
202
204
[<CompiledName( " ToSVGString" ) >]
203
- static member toSVGString
205
+ static member toSVGString
204
206
(
205
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
206
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
207
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
208
- ) =
209
- fun ( gChart : GenericChart ) ->
210
- gChart
211
- |> Chart.toSVGStringAsync( ?EngineType= EngineType, ?Width= Width, ?Height= Height)
212
- |> Async.RunSynchronously
213
-
207
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
208
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
209
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
210
+ ) =
211
+ fun ( gChart : GenericChart) ->
212
+ gChart
213
+ |> Chart.toSVGStringAsync ( ?EngineType = EngineType, ?Width = Width, ?Height = Height)
214
+ |> Async.RunSynchronously
215
+
214
216
/// <summary>
215
217
/// Returns an async function that saves a GenericChart as SVG image
216
218
/// </summary>
@@ -222,14 +224,15 @@ module ChartExtensions =
222
224
static member saveSVGAsync
223
225
(
224
226
path : string ,
225
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
226
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
227
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
228
- ) =
229
- let opts = RenderOptions( ?EngineType= EngineType, ?Width= Width, ?Height= Height)
230
-
231
- fun ( gChart : GenericChart ) -> opts.Engine.SaveSVGAsync( path, opts.Width, opts.Height, gChart)
232
-
227
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
228
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
229
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
230
+ ) =
231
+ let opts =
232
+ RenderOptions( ?EngineType = EngineType, ?Width = Width, ?Height = Height)
233
+
234
+ fun ( gChart : GenericChart ) -> opts.Engine.SaveSVGAsync( path, opts.Width, opts.Height, gChart)
235
+
233
236
/// <summary>
234
237
/// Returns a function that saves a GenericChart as SVG image
235
238
/// </summary>
@@ -241,11 +244,11 @@ module ChartExtensions =
241
244
static member saveSVG
242
245
(
243
246
path : string ,
244
- [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
245
- [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
246
- [<Optional; DefaultParameterValue( null ) >] ? Height : int
247
- ) =
248
- fun ( gChart : GenericChart ) ->
249
- gChart
250
- |> Chart.saveSVGAsync( path, ?EngineType= EngineType, ?Width= Width, ?Height= Height)
251
- |> Async.RunSynchronously
247
+ [<Optional; DefaultParameterValue( null ) >] ? EngineType : ExportEngine ,
248
+ [<Optional; DefaultParameterValue( null ) >] ? Width : int ,
249
+ [<Optional; DefaultParameterValue( null ) >] ? Height : int
250
+ ) =
251
+ fun ( gChart : GenericChart) ->
252
+ gChart
253
+ |> Chart.saveSVGAsync ( path, ?EngineType = EngineType, ?Width = Width, ?Height = Height)
254
+ |> Async.RunSynchronously
0 commit comments