Skip to content

Commit

Permalink
wip replace obsolete DynObj functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kMutagene committed Sep 26, 2024
1 parent f16b6ae commit cdacd3b
Show file tree
Hide file tree
Showing 104 changed files with 3,117 additions and 3,117 deletions.
6 changes: 3 additions & 3 deletions src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ module GenericChartExtensions =
member this.withColorBar(colorbar: ColorBar) =
this
|> GenericChart.mapTrace (fun t ->
colorbar |> DynObj.setValue t "colorbar"
colorbar |> DynObj.withProperty t "colorbar"
t)

[<CompiledName("WithColorbar")>]
Expand Down Expand Up @@ -805,7 +805,7 @@ module GenericChartExtensions =

let updatedGrid =
let currentGrid =
match layout.TryGetTypedValue<LayoutGrid> "grid" with
match layout.TryGetTypedPropertyValue<LayoutGrid> "grid" with
| Some grid -> grid
| None -> LayoutGrid()

Expand Down Expand Up @@ -913,7 +913,7 @@ module GenericChartExtensions =
member this.WithTemplate(template: Template) =
this
|> GenericChart.mapLayout (fun l ->
template |> DynObj.setValue l "template"
template |> DynObj.withProperty l "template"
l)

// TODO: Include withLegend & withLegendStyle
Expand Down
26 changes: 13 additions & 13 deletions src/Plotly.NET/ChartAPI/Chart.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2746,7 +2746,7 @@ type Chart =

let layout = GenericChart.getLayout ch

layout.TryGetTypedValue<seq<Annotation>>("annotations")
layout.TryGetTypedPropertyValue<seq<Annotation>>("annotations")
|> Option.defaultValue Seq.empty
|> Seq.append annotations

Expand Down Expand Up @@ -2857,7 +2857,7 @@ type Chart =

let layout = GenericChart.getLayout ch

layout.TryGetTypedValue<seq<Shape>>("shapes") |> Option.defaultValue Seq.empty |> Seq.append shapes
layout.TryGetTypedPropertyValue<seq<Shape>>("shapes") |> Option.defaultValue Seq.empty |> Seq.append shapes

else
shapes
Expand Down Expand Up @@ -2885,7 +2885,7 @@ type Chart =

let layout = GenericChart.getLayout ch

layout.TryGetTypedValue<seq<Selection>>("selections")
layout.TryGetTypedPropertyValue<seq<Selection>>("selections")
|> Option.defaultValue Seq.empty
|> Seq.append selections

Expand Down Expand Up @@ -3219,10 +3219,10 @@ type Chart =
| TraceID.Carpet ->

let xAxis =
layout.TryGetTypedValue<LinearAxis> "xaxis" |> Option.defaultValue (LinearAxis.init ())
layout.TryGetTypedPropertyValue<LinearAxis> "xaxis" |> Option.defaultValue (LinearAxis.init ())

let yAxis =
layout.TryGetTypedValue<LinearAxis> "yaxis" |> Option.defaultValue (LinearAxis.init ())
layout.TryGetTypedPropertyValue<LinearAxis> "yaxis" |> Option.defaultValue (LinearAxis.init ())

let allXAxes = Layout.getXAxes layout |> Seq.map fst
let allYAxes = Layout.getYAxes layout |> Seq.map fst
Expand All @@ -3245,7 +3245,7 @@ type Chart =
| TraceID.Cartesian3D ->

let scene =
layout.TryGetTypedValue<Scene> "scene"
layout.TryGetTypedPropertyValue<Scene> "scene"
|> Option.defaultValue (Scene.init ())
|> Scene.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1))

Expand All @@ -3263,7 +3263,7 @@ type Chart =
| TraceID.Polar ->

let polar =
layout.TryGetTypedValue<Polar> "polar"
layout.TryGetTypedPropertyValue<Polar> "polar"
|> Option.defaultValue (Polar.init ())
|> Polar.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1))

Expand All @@ -3283,7 +3283,7 @@ type Chart =
| TraceID.Smith ->

let smith =
layout.TryGetTypedValue<Smith> "smith"
layout.TryGetTypedPropertyValue<Smith> "smith"
|> Option.defaultValue (Smith.init ())
|> Smith.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1))

Expand All @@ -3302,7 +3302,7 @@ type Chart =

| TraceID.Geo ->
let geo =
layout.TryGetTypedValue<Geo> "geo"
layout.TryGetTypedPropertyValue<Geo> "geo"
|> Option.defaultValue (Geo.init ())
|> Geo.style (Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1))

Expand All @@ -3320,7 +3320,7 @@ type Chart =

| TraceID.Mapbox ->
let mapbox =
layout.TryGetTypedValue<Mapbox> "mapbox"
layout.TryGetTypedPropertyValue<Mapbox> "mapbox"
|> Option.defaultValue (Mapbox.init ())
|> Mapbox.style (
Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1)
Expand All @@ -3345,7 +3345,7 @@ type Chart =
| TraceID.Ternary ->

let ternary =
layout.TryGetTypedValue<Ternary> "ternary"
layout.TryGetTypedPropertyValue<Ternary> "ternary"
|> Option.defaultValue (Ternary.init ())
|> Ternary.style (
Domain = LayoutObjects.Domain.init (Row = rowIndex - 1, Column = colIndex - 1)
Expand Down Expand Up @@ -3612,7 +3612,7 @@ type Chart =

let layout = GenericChart.getLayout ch

layout.TryGetTypedValue<seq<LayoutImage>>("images")
layout.TryGetTypedPropertyValue<seq<LayoutImage>>("images")
|> Option.defaultValue Seq.empty
|> Seq.append images

Expand Down Expand Up @@ -3647,7 +3647,7 @@ type Chart =

let layout = GenericChart.getLayout ch

layout.TryGetTypedValue<seq<UpdateMenu>>("updatemenus")
layout.TryGetTypedPropertyValue<seq<UpdateMenu>>("updatemenus")
|> Option.defaultValue Seq.empty
|> Seq.append updateMenus

Expand Down
2 changes: 1 addition & 1 deletion src/Plotly.NET/ChartAPI/GenericChart.fs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ type GenericChart =
/// <param name="gChart">the input GenericChart to get the layout size from</param>
static member tryGetLayoutSize gChart =
let layout = GenericChart.getLayout gChart
layout.TryGetTypedValue<int> "width", layout.TryGetTypedValue<int> "height"
layout.TryGetTypedPropertyValue<int> "width", layout.TryGetTypedPropertyValue<int> "height"

/// <summary>
/// Returns the config of a given GenericChart.
Expand Down
14 changes: 7 additions & 7 deletions src/Plotly.NET/CommonAbstractions/AutoRangeOptions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ type AutoRangeOptions() =
) =
(fun (autoRangeOptions: AutoRangeOptions) ->

ClipMax |> DynObj.setValueOpt autoRangeOptions "clipmax"
ClipMin |> DynObj.setValueOpt autoRangeOptions "clipmin"
Include |> DynObj.setValueOpt autoRangeOptions "include"
MaxAllowed |> DynObj.setValueOpt autoRangeOptions "maxallowed"
MinAllowed |> DynObj.setValueOpt autoRangeOptions "minallowed"

autoRangeOptions)
autoRangeOptions
|> DynObj.withOptionalProperty "clipmax" ClipMax
|> DynObj.withOptionalProperty "clipmin" ClipMin
|> DynObj.withOptionalProperty "include" Include
|> DynObj.withOptionalProperty "maxallowed" MaxAllowed
|> DynObj.withOptionalProperty "minallowed" MinAllowed
)
96 changes: 48 additions & 48 deletions src/Plotly.NET/CommonAbstractions/ColorBar.fs
Original file line number Diff line number Diff line change
Expand Up @@ -254,52 +254,52 @@ type ColorBar() =
) =

(fun (colorBar: ColorBar) ->
colorBar
|> DynObj.withOptionalProperty "bgcolor" BGColor
|> DynObj.withOptionalProperty "bordercolor" BorderColor
|> DynObj.withOptionalProperty "borderwidth" BorderWidth
|> DynObj.withOptionalProperty "dtick" DTick
|> DynObj.withOptionalPropertyBy "exponentformat" ExponentFormat StyleParam.ExponentFormat.convert
|> DynObj.withOptionalProperty "labelalias" LabelAlias
|> DynObj.withOptionalProperty "len" Len
|> DynObj.withOptionalPropertyBy "lenmode" LenMode StyleParam.UnitMode.convert
|> DynObj.withOptionalProperty "min3xponent" MinExponent
|> DynObj.withOptionalProperty "nticks" NTicks
|> DynObj.withOptionalPropertyBy "orientation" Orientation StyleParam.Orientation.convert
|> DynObj.withOptionalProperty "outlinecolor" OutlineColor
|> DynObj.withOptionalProperty "outlinewidth" OutlineWidth
|> DynObj.withOptionalProperty "separatethousands" SeparateThousands
|> DynObj.withOptionalPropertyBy "showexponent" ShowExponent StyleParam.ShowExponent.convert
|> DynObj.withOptionalProperty "showticklabels" ShowTickLabels
|> DynObj.withOptionalPropertyBy "showtickprefix" ShowTickPrefix StyleParam.ShowTickOption.convert
|> DynObj.withOptionalPropertyBy "showticksuffix" ShowTickSuffix StyleParam.ShowTickOption.convert
|> DynObj.withOptionalProperty "thickness" Thickness
|> DynObj.withOptionalPropertyBy "thicknessmode" ThicknessMode StyleParam.UnitMode.convert
|> DynObj.withOptionalProperty "tick0" Tick0
|> DynObj.withOptionalProperty "tickangle" TickAngle
|> DynObj.withOptionalProperty "tickcolor" TickColor
|> DynObj.withOptionalProperty "tickfont" TickFont
|> DynObj.withOptionalProperty "tickformat" TickFormat
|> DynObj.withOptionalProperty "tickformatstops" TickFormatStops
|> DynObj.withOptionalPropertyBy "ticklabeloverflow" TickLabelOverflow StyleParam.TickLabelOverflow.convert
|> DynObj.withOptionalPropertyBy "ticklabelposition" TickLabelPosition StyleParam.TickLabelPosition.convert
|> DynObj.withOptionalProperty "ticklabelstep" TickLabelStep
|> DynObj.withOptionalProperty "ticklen" TickLen
|> DynObj.withOptionalPropertyBy "tickmode" TickMode StyleParam.TickMode.convert
|> DynObj.withOptionalProperty "tickprefix" TickPrefix
|> DynObj.withOptionalPropertyBy "ticks" Ticks StyleParam.TickOptions.convert
|> DynObj.withOptionalProperty "ticksuffix" TickSuffix
|> DynObj.withOptionalProperty "ticktext" TickText
|> DynObj.withOptionalProperty "tickvals" TickVals
|> DynObj.withOptionalProperty "tickwidth" TickWidth
|> DynObj.withOptionalProperty "title" Title
|> DynObj.withOptionalProperty "x" X
|> DynObj.withOptionalPropertyBy "xanchor" XAnchor StyleParam.HorizontalAlign.convert
|> DynObj.withOptionalProperty "xpad" XPad
|> DynObj.withOptionalProperty "xref" XRef
|> DynObj.withOptionalProperty "y" Y
|> DynObj.withOptionalPropertyBy "yanchor" YAnchor StyleParam.VerticalAlign.convert
|> DynObj.withOptionalProperty "ypad" YPad
|> DynObj.withOptionalProperty "yref" YRef

BGColor |> DynObj.setValueOpt colorBar "bgcolor"
BorderColor |> DynObj.setValueOpt colorBar "bordercolor"
BorderWidth |> DynObj.setValueOpt colorBar "borderwidth"
DTick |> DynObj.setValueOpt colorBar "dtick"
ExponentFormat |> DynObj.setValueOptBy colorBar "exponentformat" StyleParam.ExponentFormat.convert
LabelAlias |> DynObj.setValueOpt colorBar "labelalias"
Len |> DynObj.setValueOpt colorBar "len"
LenMode |> DynObj.setValueOptBy colorBar "lenmode" StyleParam.UnitMode.convert
MinExponent |> DynObj.setValueOpt colorBar "min3xponent"
NTicks |> DynObj.setValueOpt colorBar "nticks"
Orientation |> DynObj.setValueOptBy colorBar "orientation" StyleParam.Orientation.convert
OutlineColor |> DynObj.setValueOpt colorBar "outlinecolor"
OutlineWidth |> DynObj.setValueOpt colorBar "outlinewidth"
SeparateThousands |> DynObj.setValueOpt colorBar "separatethousands"
ShowExponent |> DynObj.setValueOptBy colorBar "showexponent" StyleParam.ShowExponent.convert
ShowTickLabels |> DynObj.setValueOpt colorBar "showticklabels"
ShowTickPrefix |> DynObj.setValueOptBy colorBar "showtickprefix" StyleParam.ShowTickOption.convert
ShowTickSuffix |> DynObj.setValueOptBy colorBar "showticksuffix" StyleParam.ShowTickOption.convert
Thickness |> DynObj.setValueOpt colorBar "thickness"
ThicknessMode |> DynObj.setValueOptBy colorBar "thicknessmode" StyleParam.UnitMode.convert
Tick0 |> DynObj.setValueOpt colorBar "tick0"
TickAngle |> DynObj.setValueOpt colorBar "tickangle"
TickColor |> DynObj.setValueOpt colorBar "tickcolor"
TickFont |> DynObj.setValueOpt colorBar "tickfont"
TickFormat |> DynObj.setValueOpt colorBar "tickformat"
TickFormatStops |> DynObj.setValueOpt colorBar "tickformatstops"
TickLabelOverflow |> DynObj.setValueOptBy colorBar "ticklabeloverflow" StyleParam.TickLabelOverflow.convert
TickLabelPosition |> DynObj.setValueOptBy colorBar "ticklabelposition" StyleParam.TickLabelPosition.convert
TickLabelStep |> DynObj.setValueOpt colorBar "ticklabelstep"
TickLen |> DynObj.setValueOpt colorBar "ticklen"
TickMode |> DynObj.setValueOptBy colorBar "tickmode" StyleParam.TickMode.convert
TickPrefix |> DynObj.setValueOpt colorBar "tickprefix"
Ticks |> DynObj.setValueOptBy colorBar "ticks" StyleParam.TickOptions.convert
TickSuffix |> DynObj.setValueOpt colorBar "ticksuffix"
TickText |> DynObj.setValueOpt colorBar "ticktext"
TickVals |> DynObj.setValueOpt colorBar "tickvals"
TickWidth |> DynObj.setValueOpt colorBar "tickwidth"
Title |> DynObj.setValueOpt colorBar "title"
X |> DynObj.setValueOpt colorBar "x"
XAnchor |> DynObj.setValueOptBy colorBar "xanchor" StyleParam.HorizontalAlign.convert
XPad |> DynObj.setValueOpt colorBar "xpad"
XRef |> DynObj.setValueOpt colorBar "xref"
Y |> DynObj.setValueOpt colorBar "y"
YAnchor |> DynObj.setValueOptBy colorBar "yanchor" StyleParam.VerticalAlign.convert
YPad |> DynObj.setValueOpt colorBar "ypad"
YRef |> DynObj.setValueOpt colorBar "yref"

colorBar)
)
11 changes: 5 additions & 6 deletions src/Plotly.NET/CommonAbstractions/Font.fs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@ type Font() =
[<Optional; DefaultParameterValue(null)>] ?Color: Color
) =
(fun (font: Font) ->

Family |> DynObj.setValueOptBy font "family" StyleParam.FontFamily.toString
Size |> DynObj.setValueOpt font "size"
Color |> DynObj.setValueOpt font "color"

font)
font
|> DynObj.withOptionalPropertyBy "family" Family StyleParam.FontFamily.toString
|> DynObj.withOptionalProperty "size" Size
|> DynObj.withOptionalProperty "color" Color
)
43 changes: 22 additions & 21 deletions src/Plotly.NET/CommonAbstractions/Line.fs
Original file line number Diff line number Diff line change
Expand Up @@ -125,25 +125,26 @@ type Line() =
[<Optional; DefaultParameterValue(null)>] ?OutlierWidth: float
) =
(fun (line: Line) ->
BackOff |> DynObj.setValueOptBy line "backoff" StyleParam.BackOff.convert
Color |> DynObj.setValueOpt line "color"
(Width, MultiWidth) |> DynObj.setSingleOrMultiOpt line "width"
Shape |> DynObj.setValueOptBy line "shape" StyleParam.Shape.convert
Smoothing |> DynObj.setValueOpt line "smoothing"
Dash |> DynObj.setValueOptBy line "dash" StyleParam.DrawingStyle.convert
OutlierColor |> DynObj.setValueOpt line "outliercolor"
OutlierWidth |> DynObj.setValueOpt line "outlierwidth"
AutoColorScale |> DynObj.setValueOpt line "autocolorscale"
CAuto |> DynObj.setValueOpt line "cauto"
CMax |> DynObj.setValueOpt line "cmax"
CMid |> DynObj.setValueOpt line "cmid"
CMin |> DynObj.setValueOpt line "cmin"
Color |> DynObj.setValueOpt line "color"
ColorAxis |> DynObj.setValueOptBy line "coloraxis" StyleParam.SubPlotId.convert
Colorscale |> DynObj.setValueOptBy line "colorscale" StyleParam.Colorscale.convert
ReverseScale |> DynObj.setValueOpt line "reversescale"
ShowScale |> DynObj.setValueOpt line "showscale"
ColorBar |> DynObj.setValueOpt line "colorbar"
Simplify |> DynObj.setValueOpt line "simplify"
line
|> DynObj.withOptionalPropertyBy "backoff" BackOff StyleParam.BackOff.convert
|> DynObj.withOptionalProperty "color" Color
|> DynObj.withOptionalSingleOrMultiProperty "width" (Width, MultiWidth)
|> DynObj.withOptionalPropertyBy "shape" Shape StyleParam.Shape.convert
|> DynObj.withOptionalProperty "smoothing" Smoothing
|> DynObj.withOptionalPropertyBy "dash" Dash StyleParam.DrawingStyle.convert
|> DynObj.withOptionalProperty "outliercolor" OutlierColor
|> DynObj.withOptionalProperty "outlierwidth" OutlierWidth
|> DynObj.withOptionalProperty "autocolorscale" AutoColorScale
|> DynObj.withOptionalProperty "cauto" CAuto
|> DynObj.withOptionalProperty "cmax" CMax
|> DynObj.withOptionalProperty "cmid" CMid
|> DynObj.withOptionalProperty "cmin" CMin
|> DynObj.withOptionalProperty "color" Color
|> DynObj.withOptionalPropertyBy "coloraxis" ColorAxis StyleParam.SubPlotId.convert
|> DynObj.withOptionalPropertyBy "colorscale" Colorscale StyleParam.Colorscale.convert
|> DynObj.withOptionalProperty "reversescale" ReverseScale
|> DynObj.withOptionalProperty "showscale" ShowScale
|> DynObj.withOptionalProperty "colorbar" ColorBar
|> DynObj.withOptionalProperty "simplify" Simplify

line)
)
Loading

0 comments on commit cdacd3b

Please sign in to comment.