Skip to content

Commit bc31d9b

Browse files
committed
finish port of source code to dynobj v4
1 parent 831b59d commit bc31d9b

File tree

7 files changed

+37
-42
lines changed

7 files changed

+37
-42
lines changed

src/Plotly.NET.ImageExport/PuppeteerSharpRenderer.fs

+6-5
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,13 @@ type PuppeteerSharpRenderer() =
3131

3232
gChart
3333
|> GenericChart.mapConfig (fun c ->
34-
DynObj.SetProperty c "responsive" true
35-
c)
34+
c |> DynObj.withProperty "responsive" true
35+
)
3636
|> GenericChart.mapLayout (fun l ->
37-
DynObj.SetProperty l "width" "100%"
38-
DynObj.SetProperty l "height" "100%"
39-
l)
37+
l
38+
|> DynObj.withProperty "width" "100%"
39+
|> DynObj.withProperty "height" "100%"
40+
)
4041
|> GenericChart.toEmbeddedHTML
4142
// this should be done via regex, as this only captures the default width and height.
4243
|> fun html -> html.Replace("width: 600px; height: 600px;", "width: 100%; height: 100%;")

src/Plotly.NET/ChartAPI/Chart.fs

+8-15
Original file line numberDiff line numberDiff line change
@@ -1131,8 +1131,7 @@ type Chart =
11311131
| StyleParam.SubPlotId.ZAxis -> scene |> Scene.getZAxis
11321132
| _ -> failwith "invalid scene axis id"
11331133

1134-
let updatedAxis =
1135-
(DynObj.combine currentAxis axis) :?> LinearAxis
1134+
let updatedAxis = DynObj.combine currentAxis axis
11361135

11371136
let updatedScene =
11381137
scene
@@ -1752,8 +1751,7 @@ type Chart =
17521751
let currentAxis =
17531752
polar |> Polar.getAngularAxis
17541753

1755-
let updatedAxis =
1756-
(DynObj.combine currentAxis angularAxis) :?> AngularAxis
1754+
let updatedAxis = DynObj.combine currentAxis angularAxis
17571755

17581756
let updatedPolar =
17591757
polar |> Polar.setAngularAxis updatedAxis
@@ -1812,7 +1810,7 @@ type Chart =
18121810
polar |> Polar.getRadialAxis
18131811

18141812
let updatedAxis =
1815-
(DynObj.combine currentAxis radialAxis) :?> RadialAxis
1813+
DynObj.combine currentAxis radialAxis
18161814

18171815
let updatedPolar =
18181816
polar |> Polar.setRadialAxis updatedAxis
@@ -1927,8 +1925,7 @@ type Chart =
19271925
let currentAxis =
19281926
smith |> Smith.getImaginaryAxis
19291927

1930-
let updatedAxis =
1931-
(DynObj.combine currentAxis imaginaryAxis) :?> ImaginaryAxis
1928+
let updatedAxis = DynObj.combine currentAxis imaginaryAxis
19321929

19331930
let updatedSmith =
19341931
smith |> Smith.setImaginaryAxis updatedAxis
@@ -1985,8 +1982,7 @@ type Chart =
19851982
if combine then
19861983
let currentAxis = smith |> Smith.getRealAxis
19871984

1988-
let updatedAxis =
1989-
(DynObj.combine currentAxis realAxis) :?> RealAxis
1985+
let updatedAxis = DynObj.combine currentAxis realAxis
19901986

19911987
let updatedSmith =
19921988
smith |> Smith.setRealAxis updatedAxis
@@ -2368,8 +2364,7 @@ type Chart =
23682364
let currentAxis =
23692365
ternary |> Ternary.getAAxis
23702366

2371-
let updatedAxis =
2372-
(DynObj.combine currentAxis aAxis) :?> LinearAxis
2367+
let updatedAxis = DynObj.combine currentAxis aAxis
23732368

23742369
let updatedTernary =
23752370
ternary |> Ternary.setAAxis updatedAxis
@@ -2428,8 +2423,7 @@ type Chart =
24282423
let currentAxis =
24292424
ternary |> Ternary.getBAxis
24302425

2431-
let updatedAxis =
2432-
(DynObj.combine currentAxis bAxis) :?> LinearAxis
2426+
let updatedAxis = DynObj.combine currentAxis bAxis
24332427

24342428
let updatedTernary =
24352429
ternary |> Ternary.setBAxis updatedAxis
@@ -2488,8 +2482,7 @@ type Chart =
24882482
let currentAxis =
24892483
ternary |> Ternary.getCAxis
24902484

2491-
let updatedAxis =
2492-
(DynObj.combine currentAxis cAxis) :?> LinearAxis
2485+
let updatedAxis = DynObj.combine currentAxis cAxis
24932486

24942487
let updatedTernary =
24952488
ternary |> Ternary.setCAxis updatedAxis

src/Plotly.NET/Config/Config.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ type Config() =
261261
[<Optional; DefaultParameterValue(null)>] ?Locales: obj
262262
) =
263263
fun (config: Config) ->
264-
264+
265265
config
266266
|> DynObj.withOptionalProperty "staticPlot" StaticPlot
267267
|> DynObj.withOptionalProperty "typesetMath" TypesetMath

src/Plotly.NET/Traces/Trace.fs

+1
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,7 @@ type TraceStyle() =
748748
|> DynObj.withOptionalSingleOrMultiProperty "hovertemplate" (HoverTemplate, MultiHoverTemplate)
749749
|> DynObj.withOptionalProperty "textfont" TextFont
750750

751+
751752
// <summary>
752753
/// Returns a function that applies the given styles to the trace's domain object.
753754
/// </summary>

tests/CoreTests/CoreTests/ConfigObjects/Config.fs

+6-6
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,20 @@ let ``Config API tests`` =
122122
testList "ConfigObjects.Config API" [
123123
testCase "combine ModeBarButtonsToRemove" (fun _ ->
124124
Expect.sequenceEqual
125-
(combined.TryGetTypedValue<seq<string>>("modeBarButtonsToRemove")).Value
126-
(expectedCombined.TryGetTypedValue<seq<string>>("modeBarButtonsToRemove")).Value
125+
(combined.TryGetTypedPropertyValue<seq<string>>("modeBarButtonsToRemove")).Value
126+
(expectedCombined.TryGetTypedPropertyValue<seq<string>>("modeBarButtonsToRemove")).Value
127127
"Config.combine did not return the correct object"
128128
)
129129
testCase "combine ModeBarButtonsToAdd" (fun _ ->
130130
Expect.sequenceEqual
131-
(combined.TryGetTypedValue<seq<string>>("modeBarButtonsToAdd")).Value
132-
(expectedCombined.TryGetTypedValue<seq<string>>("modeBarButtonsToAdd")).Value
131+
(combined.TryGetTypedPropertyValue<seq<string>>("modeBarButtonsToAdd")).Value
132+
(expectedCombined.TryGetTypedPropertyValue<seq<string>>("modeBarButtonsToAdd")).Value
133133
"Config.combine did not return the correct object"
134134
)
135135
testCase "combine ModeBarButtons" (fun _ ->
136136
Expect.sequenceEqual
137-
(Seq.concat (combined.TryGetTypedValue<seq<seq<string>>>("modeBarButtons")).Value)
138-
(Seq.concat (expectedCombined.TryGetTypedValue<seq<seq<string>>>("modeBarButtons")).Value)
137+
(Seq.concat (combined.TryGetTypedPropertyValue<seq<seq<string>>>("modeBarButtons")).Value)
138+
(Seq.concat (expectedCombined.TryGetTypedPropertyValue<seq<seq<string>>>("modeBarButtons")).Value)
139139
"Config.combine did not return the correct object"
140140
)
141141
]

tests/CoreTests/CoreTests/LayoutObjects/Layout.fs

+14-14
Original file line numberDiff line numberDiff line change
@@ -204,44 +204,44 @@ let ``Layout combine API tests`` =
204204
testList "LayoutObjects.Layout API" [
205205
testCase "combine Annotations" (fun _ ->
206206
Expect.sequenceEqual
207-
(combined.TryGetTypedValue<seq<Annotation>>("annotations")).Value
208-
(expectedCombined.TryGetTypedValue<seq<Annotation>>("annotations")).Value
207+
(combined.TryGetTypedPropertyValue<seq<Annotation>>("annotations")).Value
208+
(expectedCombined.TryGetTypedPropertyValue<seq<Annotation>>("annotations")).Value
209209
"Layout.combine did not return the correct object"
210210
)
211211
testCase "combine Shapes" (fun _ ->
212212
Expect.sequenceEqual
213-
(combined.TryGetTypedValue<seq<Shape>>("shapes")).Value
214-
(expectedCombined.TryGetTypedValue<seq<Shape>>("shapes")).Value
213+
(combined.TryGetTypedPropertyValue<seq<Shape>>("shapes")).Value
214+
(expectedCombined.TryGetTypedPropertyValue<seq<Shape>>("shapes")).Value
215215
"Layout.combine did not return the correct object"
216216
)
217217
testCase "combine Selections" (fun _ ->
218218
Expect.sequenceEqual
219-
(combined.TryGetTypedValue<seq<Selection>>("selections")).Value
220-
(expectedCombined.TryGetTypedValue<seq<Selection>>("selections")).Value
219+
(combined.TryGetTypedPropertyValue<seq<Selection>>("selections")).Value
220+
(expectedCombined.TryGetTypedPropertyValue<seq<Selection>>("selections")).Value
221221
"Layout.combine did not return the correct object"
222222
)
223223
testCase "combine Images" (fun _ ->
224224
Expect.sequenceEqual
225-
(combined.TryGetTypedValue<seq<LayoutImage>>("images")).Value
226-
(expectedCombined.TryGetTypedValue<seq<LayoutImage>>("images")).Value
225+
(combined.TryGetTypedPropertyValue<seq<LayoutImage>>("images")).Value
226+
(expectedCombined.TryGetTypedPropertyValue<seq<LayoutImage>>("images")).Value
227227
"Layout.combine did not return the correct object"
228228
)
229229
testCase "combine Sliders" (fun _ ->
230230
Expect.sequenceEqual
231-
(combined.TryGetTypedValue<seq<Slider>>("sliders")).Value
232-
(expectedCombined.TryGetTypedValue<seq<Slider>>("sliders")).Value
231+
(combined.TryGetTypedPropertyValue<seq<Slider>>("sliders")).Value
232+
(expectedCombined.TryGetTypedPropertyValue<seq<Slider>>("sliders")).Value
233233
"Layout.combine did not return the correct object"
234234
)
235235
testCase "combine HiddenLabels" (fun _ ->
236236
Expect.sequenceEqual
237-
(combined.TryGetTypedValue<seq<string>>("hiddenlabels")).Value
238-
(expectedCombined.TryGetTypedValue<seq<string>>("hiddenlabels")).Value
237+
(combined.TryGetTypedPropertyValue<seq<string>>("hiddenlabels")).Value
238+
(expectedCombined.TryGetTypedPropertyValue<seq<string>>("hiddenlabels")).Value
239239
"Layout.combine did not return the correct object"
240240
)
241241
testCase "combine UpdateMenus" (fun _ ->
242242
Expect.sequenceEqual
243-
(combined.TryGetTypedValue<seq<UpdateMenu>>("updatemenus")).Value
244-
(expectedCombined.TryGetTypedValue<seq<UpdateMenu>>("updatemenus")).Value
243+
(combined.TryGetTypedPropertyValue<seq<UpdateMenu>>("updatemenus")).Value
244+
(expectedCombined.TryGetTypedPropertyValue<seq<UpdateMenu>>("updatemenus")).Value
245245
"Layout.combine did not return the correct object"
246246
)
247247
]

tests/ExtensionLibsTests/CSharpTests/ExtensionMethodsTests.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public void CanUseCSharpExtensionMethod()
1818
.GetTraces()
1919
[0];
2020

21-
Assert.Equal("Trace Name", DynamicObj.DynamicObj.GetValue(actual,"name"));
21+
Assert.Equal("Trace Name", actual.GetPropertyValue("name"));
2222
}
2323

2424
[Fact]

0 commit comments

Comments
 (0)