Skip to content

Commit

Permalink
port leftover layout objects to dynobj v4
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Oct 15, 2024
1 parent b84581d commit 5064b7b
Show file tree
Hide file tree
Showing 18 changed files with 329 additions and 360 deletions.
8 changes: 4 additions & 4 deletions src/Plotly.NET/Layout/ObjectAbstractions/3D/AspectRatio.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ type AspectRatio() =

fun (aspectRatio: AspectRatio) ->

X |> DynObj.setOptionalProperty aspectRatio "x"
Y |> DynObj.setOptionalProperty aspectRatio "y"
Z |> DynObj.setOptionalProperty aspectRatio "z"

aspectRatio
|> DynObj.withOptionalProperty "x" X
|> DynObj.withOptionalProperty "y" Y
|> DynObj.withOptionalProperty "z" Z

38 changes: 18 additions & 20 deletions src/Plotly.NET/Layout/ObjectAbstractions/3D/Camera.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ type CameraCenter() =
) =

fun (cameraCenter: CameraCenter) ->

X |> DynObj.setOptionalProperty cameraCenter "x"
Y |> DynObj.setOptionalProperty cameraCenter "y"
Z |> DynObj.setOptionalProperty cameraCenter "z"


cameraCenter
|> DynObj.withOptionalProperty "x" X
|> DynObj.withOptionalProperty "y" Y
|> DynObj.withOptionalProperty "z" Z

type CameraEye() =
inherit DynamicObj()
Expand All @@ -53,11 +52,10 @@ type CameraEye() =

fun (cameraEye: CameraEye) ->

X |> DynObj.setOptionalProperty cameraEye "x"
Y |> DynObj.setOptionalProperty cameraEye "y"
Z |> DynObj.setOptionalProperty cameraEye "z"

cameraEye
|> DynObj.withOptionalProperty "x" X
|> DynObj.withOptionalProperty "y" Y
|> DynObj.withOptionalProperty "z" Z

type CameraUp() =
inherit DynamicObj()
Expand All @@ -79,11 +77,11 @@ type CameraUp() =

fun (cameraUp: CameraUp) ->

X |> DynObj.setOptionalProperty cameraUp "x"
Y |> DynObj.setOptionalProperty cameraUp "y"
Z |> DynObj.setOptionalProperty cameraUp "z"

cameraUp
|> DynObj.withOptionalProperty "x" X
|> DynObj.withOptionalProperty "y" Y
|> DynObj.withOptionalProperty "z" Z


type CameraProjection() =
inherit DynamicObj()
Expand All @@ -95,9 +93,9 @@ type CameraProjection() =

fun (cameraProjection: CameraProjection) ->

ProjectionType |> DynObj.setOptionalPropertyBy cameraProjection "type" StyleParam.CameraProjectionType.convert
cameraProjection |> DynObj.withOptionalPropertyBy "type" ProjectionType StyleParam.CameraProjectionType.convert

cameraProjection


type Camera() =
inherit DynamicObj()
Expand All @@ -121,9 +119,9 @@ type Camera() =

fun (camera: Camera) ->

Center |> DynObj.setOptionalProperty camera "center"
Eye |> DynObj.setOptionalProperty camera "eye"
Projection |> DynObj.setOptionalProperty camera "projection"
Up |> DynObj.setOptionalProperty camera "up"

camera
|> DynObj.withOptionalProperty "center" Center
|> DynObj.withOptionalProperty "eye" Eye
|> DynObj.withOptionalProperty "projection" Projection
|> DynObj.withOptionalProperty "up" Up

29 changes: 14 additions & 15 deletions src/Plotly.NET/Layout/ObjectAbstractions/3D/Scene.fs
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,21 @@ type Scene() =
[<Optional; DefaultParameterValue(null)>] ?YAxis: LinearAxis,
[<Optional; DefaultParameterValue(null)>] ?ZAxis: LinearAxis
) =
(fun (scene: Scene) ->

Annotations |> DynObj.setOptionalProperty scene "annotations"
AspectMode |> DynObj.setOptionalPropertyBy scene "aspectmode" StyleParam.AspectMode.convert
AspectRatio |> DynObj.setOptionalProperty scene "aspectratio"
BGColor |> DynObj.setOptionalProperty scene "bgcolor"
Camera |> DynObj.setOptionalProperty scene "camera"
Domain |> DynObj.setOptionalProperty scene "domain"
DragMode |> DynObj.setOptionalPropertyBy scene "dragmode" StyleParam.DragMode.convert
HoverMode |> DynObj.setOptionalPropertyBy scene "hovermode" StyleParam.HoverMode.convert
UIRevision |> DynObj.setOptionalProperty scene "uirevision"
XAxis |> DynObj.setOptionalProperty scene "xaxis"
YAxis |> DynObj.setOptionalProperty scene "yaxis"
ZAxis |> DynObj.setOptionalProperty scene "zaxis"
fun (scene: Scene) ->

scene)
scene
|> DynObj.withOptionalProperty "annotations" Annotations
|> DynObj.withOptionalPropertyBy "aspectmode" AspectMode StyleParam.AspectMode.convert
|> DynObj.withOptionalProperty "aspectratio" AspectRatio
|> DynObj.withOptionalProperty "bgcolor" BGColor
|> DynObj.withOptionalProperty "camera" Camera
|> DynObj.withOptionalProperty "domain" Domain
|> DynObj.withOptionalPropertyBy "dragmode" DragMode StyleParam.DragMode.convert
|> DynObj.withOptionalPropertyBy "hovermode" HoverMode StyleParam.HoverMode.convert
|> DynObj.withOptionalProperty "uirevision" UIRevision
|> DynObj.withOptionalProperty "xaxis" XAxis
|> DynObj.withOptionalProperty "yaxis" YAxis
|> DynObj.withOptionalProperty "zaxis" ZAxis

/// <summary>
/// Returns Some(dynamic member value) of the scene object's underlying DynamicObj when a dynamic member with the given name exists, and None otherwise.
Expand Down
5 changes: 2 additions & 3 deletions src/Plotly.NET/Layout/ObjectAbstractions/Common/Shape.fs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ type Shape() =
[<Optional; DefaultParameterValue(null)>] ?Yref: string,
[<Optional; DefaultParameterValue(null)>] ?YSizeMode: StyleParam.ShapeSizeMode
) =
(fun (shape: Shape) ->
fun (shape: Shape) ->

shape
|> DynObj.withProperty "editable" Editable
Expand Down Expand Up @@ -227,5 +227,4 @@ type Shape() =
|> DynObj.withProperty "y1" Y1
|> DynObj.withOptionalPropertyBy "yanchor" YAnchor StyleParam.LinearAxisId.convert
|> DynObj.withProperty "yref" Yref
|> DynObj.withOptionalPropertyBy "ysizemode" YSizeMode StyleParam.ShapeSizeMode.convert)
)
|> DynObj.withOptionalPropertyBy "ysizemode" YSizeMode StyleParam.ShapeSizeMode.convert
81 changes: 40 additions & 41 deletions src/Plotly.NET/Layout/ObjectAbstractions/Map/Geo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -177,46 +177,45 @@ type Geo() =
[<Optional; DefaultParameterValue(null)>] ?LatAxis: LinearAxis,
[<Optional; DefaultParameterValue(null)>] ?LonAxis: LinearAxis
) =
(fun (geo: Geo) ->
fun (geo: Geo) ->

Domain |> DynObj.setOptionalProperty geo "domain"
FitBounds |> DynObj.setOptionalPropertyBy geo "fitbounds" StyleParam.GeoFitBounds.convert
Resolution |> DynObj.setOptionalPropertyBy geo "resolution" StyleParam.GeoResolution.convert
Scope |> DynObj.setOptionalPropertyBy geo "scope" StyleParam.GeoScope.convert
Projection |> DynObj.setOptionalProperty geo "projection"
let center =
Center
|> Option.map (fun (lon, lat) ->
DynamicObj()
|> DynObj.withProperty "lon" lon
|> DynObj.withProperty "lat" lat
)

Center
|> Option.map (fun (lon, lat) ->
let t = DynamicObj()
t?lon <- lon
t?lat <- lat
t)
|> DynObj.setOptionalProperty geo "center"

Visible |> DynObj.setOptionalProperty geo "visible"
ShowCoastLines |> DynObj.setOptionalProperty geo "showcoastline"
CoastLineColor |> DynObj.setOptionalProperty geo "coastlinecolor"
CoastLineWidth |> DynObj.setOptionalProperty geo "coastlinewidth"
ShowLand |> DynObj.setOptionalProperty geo "showland"
LandColor |> DynObj.setOptionalProperty geo "landcolor"
ShowOcean |> DynObj.setOptionalProperty geo "showocean"
OceanColor |> DynObj.setOptionalProperty geo "oceancolor"
ShowLakes |> DynObj.setOptionalProperty geo "showlakes"
LakeColor |> DynObj.setOptionalProperty geo "lakecolor"
ShowRivers |> DynObj.setOptionalProperty geo "showrivers"
RiverColor |> DynObj.setOptionalProperty geo "rivercolor"
RiverWidth |> DynObj.setOptionalProperty geo "riverwidth"
ShowCountries |> DynObj.setOptionalProperty geo "showcountries"
CountryColor |> DynObj.setOptionalProperty geo "countrycolor"
CountryWidth |> DynObj.setOptionalProperty geo "countrywidth"
ShowSubunits |> DynObj.setOptionalProperty geo "showsubunits"
SubunitColor |> DynObj.setOptionalProperty geo "subunitcolor"
SubunitWidth |> DynObj.setOptionalProperty geo "subunitwidth"
ShowFrame |> DynObj.setOptionalProperty geo "showframe"
FrameColor |> DynObj.setOptionalProperty geo "framecolor"
FrameWidth |> DynObj.setOptionalProperty geo "framewidth"
BgColor |> DynObj.setOptionalProperty geo "bgcolor"
LatAxis |> DynObj.setOptionalProperty geo "lataxis"
LonAxis |> DynObj.setOptionalProperty geo "lonaxis"

geo)
geo
|> DynObj.withOptionalProperty "domain" Domain
|> DynObj.withOptionalPropertyBy "fitbounds" FitBounds StyleParam.GeoFitBounds.convert
|> DynObj.withOptionalPropertyBy "resolution" Resolution StyleParam.GeoResolution.convert
|> DynObj.withOptionalPropertyBy "scope" Scope StyleParam.GeoScope.convert
|> DynObj.withOptionalProperty "projection" Projection
|> DynObj.withOptionalProperty "center" center
|> DynObj.withOptionalProperty "visible" Visible
|> DynObj.withOptionalProperty "showcoastline" ShowCoastLines
|> DynObj.withOptionalProperty "coastlinecolor" CoastLineColor
|> DynObj.withOptionalProperty "coastlinewidth" CoastLineWidth
|> DynObj.withOptionalProperty "showland" ShowLand
|> DynObj.withOptionalProperty "landcolor" LandColor
|> DynObj.withOptionalProperty "showocean" ShowOcean
|> DynObj.withOptionalProperty "oceancolor" OceanColor
|> DynObj.withOptionalProperty "showlakes" ShowLakes
|> DynObj.withOptionalProperty "lakecolor" LakeColor
|> DynObj.withOptionalProperty "showrivers" ShowRivers
|> DynObj.withOptionalProperty "rivercolor" RiverColor
|> DynObj.withOptionalProperty "riverwidth" RiverWidth
|> DynObj.withOptionalProperty "showcountries" ShowCountries
|> DynObj.withOptionalProperty "countrycolor" CountryColor
|> DynObj.withOptionalProperty "countrywidth" CountryWidth
|> DynObj.withOptionalProperty "showsubunits" ShowSubunits
|> DynObj.withOptionalProperty "subunitcolor" SubunitColor
|> DynObj.withOptionalProperty "subunitwidth" SubunitWidth
|> DynObj.withOptionalProperty "showframe" ShowFrame
|> DynObj.withOptionalProperty "framecolor" FrameColor
|> DynObj.withOptionalProperty "framewidth" FrameWidth
|> DynObj.withOptionalProperty "bgcolor" BgColor
|> DynObj.withOptionalProperty "lataxis" LatAxis
|> DynObj.withOptionalProperty "lonaxis" LonAxis
25 changes: 11 additions & 14 deletions src/Plotly.NET/Layout/ObjectAbstractions/Map/GeoProjection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ type GeoProjectionRotation() =
[<Optional; DefaultParameterValue(null)>] ?Latitude: float,
[<Optional; DefaultParameterValue(null)>] ?Roll: int
) =
(fun (rotation: GeoProjectionRotation) ->
Longitude |> DynObj.setOptionalProperty rotation "lon"
Latitude |> DynObj.setOptionalProperty rotation "lat"
Roll |> DynObj.setOptionalProperty rotation "roll"
fun (rotation: GeoProjectionRotation) ->

rotation)
rotation
|> DynObj.withOptionalProperty "lon" Longitude
|> DynObj.withOptionalProperty "lat" Latitude
|> DynObj.withOptionalProperty "roll" Roll

/// <summary>Determines the map projection in geo traces.</summary>
type GeoProjection() =
Expand Down Expand Up @@ -75,13 +75,10 @@ type GeoProjection() =
[<Optional; DefaultParameterValue(null)>] ?Parallels: (float * float),
[<Optional; DefaultParameterValue(null)>] ?Scale: float
) =
(fun (projection: GeoProjection) ->
fun (projection: GeoProjection) ->

projectionType |> StyleParam.GeoProjectionType.convert |> DynObj.withProperty projection "type"

Parallels |> Option.map (fun (a, b) -> sprintf "[%f,%f]" a b) |> DynObj.setOptionalProperty projection "parallels"

Rotation |> DynObj.setOptionalProperty projection "rotation"
Scale |> DynObj.setOptionalProperty projection "scale"

projection)
projection
|> DynObj.withProperty "type" (StyleParam.GeoProjectionType.convert projectionType)
|> DynObj.withOptionalProperty "rotation" Rotation
|> DynObj.withOptionalPropertyBy "parallels" Parallels (fun (a, b) -> sprintf "[%f,%f]" a b)
|> DynObj.withOptionalProperty "scale" Scale
37 changes: 18 additions & 19 deletions src/Plotly.NET/Layout/ObjectAbstractions/Map/Mapbox.fs
Original file line number Diff line number Diff line change
Expand Up @@ -69,24 +69,23 @@ type Mapbox() =
[<Optional; DefaultParameterValue(null)>] ?Pitch: float,
[<Optional; DefaultParameterValue(null)>] ?Layers: seq<MapboxLayer>
) =
(fun (mapBox: Mapbox) ->
fun (mapBox: Mapbox) ->

Domain |> DynObj.setOptionalProperty mapBox "domain"
AccessToken |> DynObj.setOptionalProperty mapBox "accesstoken"
Style |> DynObj.setOptionalPropertyBy mapBox "style" StyleParam.MapboxStyle.convert
Bounds |> DynObj.setOptionalProperty mapBox "bounds"
let center =
Center
|> Option.map (fun (lon, lat) ->
DynamicObj()
|> DynObj.withProperty "lon" lon
|> DynObj.withProperty "lat" lat
)

Center
|> Option.map (fun (lon, lat) ->
let t = DynamicObj()
t?lon <- lon
t?lat <- lat
t)
|> DynObj.setOptionalProperty mapBox "center"

Zoom |> DynObj.setOptionalProperty mapBox "zoom"
Bearing |> DynObj.setOptionalProperty mapBox "bearing"
Pitch |> DynObj.setOptionalProperty mapBox "pitch"
Layers |> DynObj.setOptionalProperty mapBox "layers"

mapBox)
mapBox
|> DynObj.withOptionalProperty "domain" Domain
|> DynObj.withOptionalProperty "accesstoken" AccessToken
|> DynObj.withOptionalPropertyBy "style" Style StyleParam.MapboxStyle.convert
|> DynObj.withOptionalProperty "bounds" Bounds
|> DynObj.withOptionalProperty "center" center
|> DynObj.withOptionalProperty "zoom" Zoom
|> DynObj.withOptionalProperty "bearing" Bearing
|> DynObj.withOptionalProperty "pitch" Pitch
|> DynObj.withOptionalProperty "layers" Layers
13 changes: 6 additions & 7 deletions src/Plotly.NET/Layout/ObjectAbstractions/Map/MapboxBounds.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,10 @@ type MapboxBounds() =
[<Optional; DefaultParameterValue(null)>] ?South: float,
[<Optional; DefaultParameterValue(null)>] ?West: float
) =
(fun (mapboxBounds: MapboxBounds) ->
fun (mapboxBounds: MapboxBounds) ->

East |> DynObj.setOptionalProperty mapboxBounds "east"
North |> DynObj.setOptionalProperty mapboxBounds "north"
South |> DynObj.setOptionalProperty mapboxBounds "south"
West |> DynObj.setOptionalProperty mapboxBounds "west"

mapboxBounds)
mapboxBounds
|> DynObj.withOptionalProperty "east" East
|> DynObj.withOptionalProperty "north" North
|> DynObj.withOptionalProperty "south" South
|> DynObj.withOptionalProperty "west" West
18 changes: 8 additions & 10 deletions src/Plotly.NET/Layout/ObjectAbstractions/Map/MapboxCluster.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ type MapboxCluster() =
[<Optional; DefaultParameterValue(null)>] ?MultiStep: seq<int>

) =
(fun (mapboxCluster: MapboxCluster) ->

Color |> DynObj.setOptionalProperty mapboxCluster "color"
Enabled |> DynObj.setOptionalProperty mapboxCluster "enabled"
MaxZoom |> DynObj.setOptionalProperty mapboxCluster "maxzoom"
Opacity |> DynObj.setOptionalProperty mapboxCluster "opacity"
(Size, MultiSize) |> DynObj.setOptionalSingleOrMultiProperty mapboxCluster "size"
(Step, MultiStep) |> DynObj.setOptionalSingleOrMultiProperty mapboxCluster "step"

mapboxCluster)
fun (mapboxCluster: MapboxCluster) ->
mapboxCluster
|> DynObj.withOptionalProperty "color" Color
|> DynObj.withOptionalProperty "enabled" Enabled
|> DynObj.withOptionalProperty "maxzoom" MaxZoom
|> DynObj.withOptionalProperty "opacity" Opacity
|> DynObj.withOptionalSingleOrMultiProperty"size" (Size, MultiSize)
|> DynObj.withOptionalSingleOrMultiProperty"step" (Step, MultiStep)
Loading

0 comments on commit 5064b7b

Please sign in to comment.