@@ -11,16 +11,13 @@ open System.Runtime.CompilerServices
1111/// Extensions methods from Plotly.NET.ImageExport for the Chart module, supporting the fluent pipeline style
1212[<AutoOpen>]
1313module 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
2421
2522 type Chart with
2623
@@ -33,15 +30,16 @@ module ChartExtensions =
3330 [<CompiledName( " ToBase64JPGStringAsync" ) >]
3431 static member toBase64JPGStringAsync
3532 (
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+
4543 /// <summary>
4644 /// Returns a function that converts a GenericChart to a base64 encoded JPG string
4745 /// </summary>
@@ -51,14 +49,14 @@ module ChartExtensions =
5149 [<CompiledName( " ToBase64JPGString" ) >]
5250 static member toBase64JPGString
5351 (
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
6260
6361 /// <summary>
6462 /// Returns an async function that saves a GenericChart as JPG image
@@ -68,17 +66,18 @@ module ChartExtensions =
6866 /// <param name="Width">width of the resulting image</param>
6967 /// <param name="Height">height of the resulting image</param>
7068 [<CompiledName( " SaveJPGAsync" ) >]
71- static member saveJPGAsync
69+ static member saveJPGAsync
7270 (
7371 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)
7879
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)
8281
8382 /// <summary>
8483 /// Returns a function that saves a GenericChart as JPG image
@@ -91,14 +90,14 @@ module ChartExtensions =
9190 static member saveJPG
9291 (
9392 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
102101
103102 /// <summary>
104103 /// Returns an async function that converts a GenericChart to a base64 encoded PNG string
@@ -109,14 +108,15 @@ module ChartExtensions =
109108 [<CompiledName( " ToBase64PNGStringAsync" ) >]
110109 static member toBase64PNGStringAsync
111110 (
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)
120120
121121 /// <summary>
122122 /// Returns a function that converts a GenericChart to a base64 encoded PNG string
@@ -127,14 +127,14 @@ module ChartExtensions =
127127 [<CompiledName( " ToBase64PNGString" ) >]
128128 static member toBase64PNGString
129129 (
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
138138
139139 /// <summary>
140140 /// Returns an async function that saves a GenericChart as PNG image
@@ -147,13 +147,14 @@ module ChartExtensions =
147147 static member savePNGAsync
148148 (
149149 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)
157158
158159
159160 /// <summary>
@@ -167,15 +168,15 @@ module ChartExtensions =
167168 static member savePNG
168169 (
169170 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+
179180 /// <summary>
180181 /// Returns an async function that converts a GenericChart to a SVG string
181182 /// </summary>
@@ -185,13 +186,14 @@ module ChartExtensions =
185186 [<CompiledName( " ToSVGStringAsync" ) >]
186187 static member toSVGStringAsync
187188 (
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)
195197
196198 /// <summary>
197199 /// Returns a function that converts a GenericChart to a SVG string
@@ -200,17 +202,17 @@ module ChartExtensions =
200202 /// <param name="Width">width of the resulting image</param>
201203 /// <param name="Height">height of the resulting image</param>
202204 [<CompiledName( " ToSVGString" ) >]
203- static member toSVGString
205+ static member toSVGString
204206 (
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+
214216 /// <summary>
215217 /// Returns an async function that saves a GenericChart as SVG image
216218 /// </summary>
@@ -222,14 +224,15 @@ module ChartExtensions =
222224 static member saveSVGAsync
223225 (
224226 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+
233236 /// <summary>
234237 /// Returns a function that saves a GenericChart as SVG image
235238 /// </summary>
@@ -241,11 +244,11 @@ module ChartExtensions =
241244 static member saveSVG
242245 (
243246 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