Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to DynamicObj v4 #472

Merged
merged 18 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
finish port of source code to dynobj v4
  • Loading branch information
kMutagene committed Oct 15, 2024
commit bc31d9b3e7bdf7af59a0d832c8d8c2ebcf6ef0ab
11 changes: 6 additions & 5 deletions src/Plotly.NET.ImageExport/PuppeteerSharpRenderer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ type PuppeteerSharpRenderer() =

gChart
|> GenericChart.mapConfig (fun c ->
DynObj.SetProperty c "responsive" true
c)
c |> DynObj.withProperty "responsive" true
)
|> GenericChart.mapLayout (fun l ->
DynObj.SetProperty l "width" "100%"
DynObj.SetProperty l "height" "100%"
l)
l
|> DynObj.withProperty "width" "100%"
|> DynObj.withProperty "height" "100%"
)
|> GenericChart.toEmbeddedHTML
// this should be done via regex, as this only captures the default width and height.
|> fun html -> html.Replace("width: 600px; height: 600px;", "width: 100%; height: 100%;")
Expand Down
23 changes: 8 additions & 15 deletions src/Plotly.NET/ChartAPI/Chart.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1131,8 +1131,7 @@ type Chart =
| StyleParam.SubPlotId.ZAxis -> scene |> Scene.getZAxis
| _ -> failwith "invalid scene axis id"

let updatedAxis =
(DynObj.combine currentAxis axis) :?> LinearAxis
let updatedAxis = DynObj.combine currentAxis axis

let updatedScene =
scene
Expand Down Expand Up @@ -1752,8 +1751,7 @@ type Chart =
let currentAxis =
polar |> Polar.getAngularAxis

let updatedAxis =
(DynObj.combine currentAxis angularAxis) :?> AngularAxis
let updatedAxis = DynObj.combine currentAxis angularAxis

let updatedPolar =
polar |> Polar.setAngularAxis updatedAxis
Expand Down Expand Up @@ -1812,7 +1810,7 @@ type Chart =
polar |> Polar.getRadialAxis

let updatedAxis =
(DynObj.combine currentAxis radialAxis) :?> RadialAxis
DynObj.combine currentAxis radialAxis

let updatedPolar =
polar |> Polar.setRadialAxis updatedAxis
Expand Down Expand Up @@ -1927,8 +1925,7 @@ type Chart =
let currentAxis =
smith |> Smith.getImaginaryAxis

let updatedAxis =
(DynObj.combine currentAxis imaginaryAxis) :?> ImaginaryAxis
let updatedAxis = DynObj.combine currentAxis imaginaryAxis

let updatedSmith =
smith |> Smith.setImaginaryAxis updatedAxis
Expand Down Expand Up @@ -1985,8 +1982,7 @@ type Chart =
if combine then
let currentAxis = smith |> Smith.getRealAxis

let updatedAxis =
(DynObj.combine currentAxis realAxis) :?> RealAxis
let updatedAxis = DynObj.combine currentAxis realAxis

let updatedSmith =
smith |> Smith.setRealAxis updatedAxis
Expand Down Expand Up @@ -2368,8 +2364,7 @@ type Chart =
let currentAxis =
ternary |> Ternary.getAAxis

let updatedAxis =
(DynObj.combine currentAxis aAxis) :?> LinearAxis
let updatedAxis = DynObj.combine currentAxis aAxis

let updatedTernary =
ternary |> Ternary.setAAxis updatedAxis
Expand Down Expand Up @@ -2428,8 +2423,7 @@ type Chart =
let currentAxis =
ternary |> Ternary.getBAxis

let updatedAxis =
(DynObj.combine currentAxis bAxis) :?> LinearAxis
let updatedAxis = DynObj.combine currentAxis bAxis

let updatedTernary =
ternary |> Ternary.setBAxis updatedAxis
Expand Down Expand Up @@ -2488,8 +2482,7 @@ type Chart =
let currentAxis =
ternary |> Ternary.getCAxis

let updatedAxis =
(DynObj.combine currentAxis cAxis) :?> LinearAxis
let updatedAxis = DynObj.combine currentAxis cAxis

let updatedTernary =
ternary |> Ternary.setCAxis updatedAxis
Expand Down
2 changes: 1 addition & 1 deletion src/Plotly.NET/Config/Config.fs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ type Config() =
[<Optional; DefaultParameterValue(null)>] ?Locales: obj
) =
fun (config: Config) ->

config
|> DynObj.withOptionalProperty "staticPlot" StaticPlot
|> DynObj.withOptionalProperty "typesetMath" TypesetMath
Expand Down
1 change: 1 addition & 0 deletions src/Plotly.NET/Traces/Trace.fs
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,7 @@ type TraceStyle() =
|> DynObj.withOptionalSingleOrMultiProperty "hovertemplate" (HoverTemplate, MultiHoverTemplate)
|> DynObj.withOptionalProperty "textfont" TextFont


// <summary>
/// Returns a function that applies the given styles to the trace's domain object.
/// </summary>
Expand Down
12 changes: 6 additions & 6 deletions tests/CoreTests/CoreTests/ConfigObjects/Config.fs
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,20 @@ let ``Config API tests`` =
testList "ConfigObjects.Config API" [
testCase "combine ModeBarButtonsToRemove" (fun _ ->
Expect.sequenceEqual
(combined.TryGetTypedValue<seq<string>>("modeBarButtonsToRemove")).Value
(expectedCombined.TryGetTypedValue<seq<string>>("modeBarButtonsToRemove")).Value
(combined.TryGetTypedPropertyValue<seq<string>>("modeBarButtonsToRemove")).Value
(expectedCombined.TryGetTypedPropertyValue<seq<string>>("modeBarButtonsToRemove")).Value
"Config.combine did not return the correct object"
)
testCase "combine ModeBarButtonsToAdd" (fun _ ->
Expect.sequenceEqual
(combined.TryGetTypedValue<seq<string>>("modeBarButtonsToAdd")).Value
(expectedCombined.TryGetTypedValue<seq<string>>("modeBarButtonsToAdd")).Value
(combined.TryGetTypedPropertyValue<seq<string>>("modeBarButtonsToAdd")).Value
(expectedCombined.TryGetTypedPropertyValue<seq<string>>("modeBarButtonsToAdd")).Value
"Config.combine did not return the correct object"
)
testCase "combine ModeBarButtons" (fun _ ->
Expect.sequenceEqual
(Seq.concat (combined.TryGetTypedValue<seq<seq<string>>>("modeBarButtons")).Value)
(Seq.concat (expectedCombined.TryGetTypedValue<seq<seq<string>>>("modeBarButtons")).Value)
(Seq.concat (combined.TryGetTypedPropertyValue<seq<seq<string>>>("modeBarButtons")).Value)
(Seq.concat (expectedCombined.TryGetTypedPropertyValue<seq<seq<string>>>("modeBarButtons")).Value)
"Config.combine did not return the correct object"
)
]
28 changes: 14 additions & 14 deletions tests/CoreTests/CoreTests/LayoutObjects/Layout.fs
Original file line number Diff line number Diff line change
Expand Up @@ -204,44 +204,44 @@ let ``Layout combine API tests`` =
testList "LayoutObjects.Layout API" [
testCase "combine Annotations" (fun _ ->
Expect.sequenceEqual
(combined.TryGetTypedValue<seq<Annotation>>("annotations")).Value
(expectedCombined.TryGetTypedValue<seq<Annotation>>("annotations")).Value
(combined.TryGetTypedPropertyValue<seq<Annotation>>("annotations")).Value
(expectedCombined.TryGetTypedPropertyValue<seq<Annotation>>("annotations")).Value
"Layout.combine did not return the correct object"
)
testCase "combine Shapes" (fun _ ->
Expect.sequenceEqual
(combined.TryGetTypedValue<seq<Shape>>("shapes")).Value
(expectedCombined.TryGetTypedValue<seq<Shape>>("shapes")).Value
(combined.TryGetTypedPropertyValue<seq<Shape>>("shapes")).Value
(expectedCombined.TryGetTypedPropertyValue<seq<Shape>>("shapes")).Value
"Layout.combine did not return the correct object"
)
testCase "combine Selections" (fun _ ->
Expect.sequenceEqual
(combined.TryGetTypedValue<seq<Selection>>("selections")).Value
(expectedCombined.TryGetTypedValue<seq<Selection>>("selections")).Value
(combined.TryGetTypedPropertyValue<seq<Selection>>("selections")).Value
(expectedCombined.TryGetTypedPropertyValue<seq<Selection>>("selections")).Value
"Layout.combine did not return the correct object"
)
testCase "combine Images" (fun _ ->
Expect.sequenceEqual
(combined.TryGetTypedValue<seq<LayoutImage>>("images")).Value
(expectedCombined.TryGetTypedValue<seq<LayoutImage>>("images")).Value
(combined.TryGetTypedPropertyValue<seq<LayoutImage>>("images")).Value
(expectedCombined.TryGetTypedPropertyValue<seq<LayoutImage>>("images")).Value
"Layout.combine did not return the correct object"
)
testCase "combine Sliders" (fun _ ->
Expect.sequenceEqual
(combined.TryGetTypedValue<seq<Slider>>("sliders")).Value
(expectedCombined.TryGetTypedValue<seq<Slider>>("sliders")).Value
(combined.TryGetTypedPropertyValue<seq<Slider>>("sliders")).Value
(expectedCombined.TryGetTypedPropertyValue<seq<Slider>>("sliders")).Value
"Layout.combine did not return the correct object"
)
testCase "combine HiddenLabels" (fun _ ->
Expect.sequenceEqual
(combined.TryGetTypedValue<seq<string>>("hiddenlabels")).Value
(expectedCombined.TryGetTypedValue<seq<string>>("hiddenlabels")).Value
(combined.TryGetTypedPropertyValue<seq<string>>("hiddenlabels")).Value
(expectedCombined.TryGetTypedPropertyValue<seq<string>>("hiddenlabels")).Value
"Layout.combine did not return the correct object"
)
testCase "combine UpdateMenus" (fun _ ->
Expect.sequenceEqual
(combined.TryGetTypedValue<seq<UpdateMenu>>("updatemenus")).Value
(expectedCombined.TryGetTypedValue<seq<UpdateMenu>>("updatemenus")).Value
(combined.TryGetTypedPropertyValue<seq<UpdateMenu>>("updatemenus")).Value
(expectedCombined.TryGetTypedPropertyValue<seq<UpdateMenu>>("updatemenus")).Value
"Layout.combine did not return the correct object"
)
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void CanUseCSharpExtensionMethod()
.GetTraces()
[0];

Assert.Equal("Trace Name", DynamicObj.DynamicObj.GetValue(actual,"name"));
Assert.Equal("Trace Name", actual.GetPropertyValue("name"));
}

[Fact]
Expand Down