Skip to content

Commit 56cc563

Browse files
authored
Merge pull request #472 from plotly/update-to-dynobj-v4
update to DynamicObj v4
2 parents f16b6ae + dbdf8b6 commit 56cc563

File tree

118 files changed

+3637
-3894
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

118 files changed

+3637
-3894
lines changed

Diff for: docs/index.fsx

+13-13
Original file line numberDiff line numberDiff line change
@@ -290,25 +290,25 @@ double[] x = new double[] { 1, 2 };
290290
double[] y = new double[] { 5, 10 };
291291
292292
LinearAxis xAxis = new LinearAxis();
293-
xAxis.SetValue("title", "xAxis");
294-
xAxis.SetValue("showgrid", false);
295-
xAxis.SetValue("showline", true);
293+
xAxis.SetProperty("title", "xAxis");
294+
xAxis.SetProperty("showgrid", false);
295+
xAxis.SetProperty("showline", true);
296296
297297
LinearAxis yAxis = new LinearAxis();
298-
yAxis.SetValue("title", "yAxis");
299-
yAxis.SetValue("showgrid", false);
300-
yAxis.SetValue("showline", true);
298+
yAxis.SetProperty("title", "yAxis");
299+
yAxis.SetProperty("showgrid", false);
300+
yAxis.SetProperty("showline", true);
301301
302302
Layout layout = new Layout();
303-
layout.SetValue("xaxis", xAxis);
304-
layout.SetValue("yaxis", yAxis);
305-
layout.SetValue("showlegend", true);
303+
layout.SetProperty("xaxis", xAxis);
304+
layout.SetProperty("yaxis", yAxis);
305+
layout.SetProperty("showlegend", true);
306306
307307
Trace trace = new Trace("scatter");
308-
trace.SetValue("x", x);
309-
trace.SetValue("y", y);
310-
trace.SetValue("mode", "markers");
311-
trace.SetValue("name", "Hello from C#");
308+
trace.SetProperty("x", x);
309+
trace.SetProperty("y", y);
310+
trace.SetProperty("mode", "markers");
311+
trace.SetProperty("name", "Hello from C#");
312312
313313
GenericChart
314314
.ofTraceObject(true, trace)

Diff for: 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.setValue c "responsive" true
35-
c)
34+
c |> DynObj.withProperty "responsive" true
35+
)
3636
|> GenericChart.mapLayout (fun l ->
37-
DynObj.setValue l "width" "100%"
38-
DynObj.setValue 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%;")

Diff for: src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs

+5-5
Original file line numberDiff line numberDiff line change
@@ -426,8 +426,8 @@ module GenericChartExtensions =
426426
member this.withColorBar(colorbar: ColorBar) =
427427
this
428428
|> GenericChart.mapTrace (fun t ->
429-
colorbar |> DynObj.setValue t "colorbar"
430-
t)
429+
t |> DynObj.withProperty "colorbar" colorbar
430+
)
431431

432432
[<CompiledName("WithColorbar")>]
433433
[<Extension>]
@@ -805,7 +805,7 @@ module GenericChartExtensions =
805805

806806
let updatedGrid =
807807
let currentGrid =
808-
match layout.TryGetTypedValue<LayoutGrid> "grid" with
808+
match layout.TryGetTypedPropertyValue<LayoutGrid> "grid" with
809809
| Some grid -> grid
810810
| None -> LayoutGrid()
811811

@@ -913,8 +913,8 @@ module GenericChartExtensions =
913913
member this.WithTemplate(template: Template) =
914914
this
915915
|> GenericChart.mapLayout (fun l ->
916-
template |> DynObj.setValue l "template"
917-
l)
916+
l |> DynObj.withProperty "template" template
917+
)
918918

919919
// TODO: Include withLegend & withLegendStyle
920920

Diff for: src/Plotly.NET/ChartAPI/Chart.fs

+52-56
Large diffs are not rendered by default.

Diff for: src/Plotly.NET/ChartAPI/GenericChart.fs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ type GenericChart =
162162
/// <param name="gChart">the input GenericChart to get the layout size from</param>
163163
static member tryGetLayoutSize gChart =
164164
let layout = GenericChart.getLayout gChart
165-
layout.TryGetTypedValue<int> "width", layout.TryGetTypedValue<int> "height"
165+
layout.TryGetTypedPropertyValue<int> "width", layout.TryGetTypedPropertyValue<int> "height"
166166

167167
/// <summary>
168168
/// Returns the config of a given GenericChart.

Diff for: src/Plotly.NET/CommonAbstractions/AutoRangeOptions.fs

+7-7
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ type AutoRangeOptions() =
5252
) =
5353
(fun (autoRangeOptions: AutoRangeOptions) ->
5454

55-
ClipMax |> DynObj.setValueOpt autoRangeOptions "clipmax"
56-
ClipMin |> DynObj.setValueOpt autoRangeOptions "clipmin"
57-
Include |> DynObj.setValueOpt autoRangeOptions "include"
58-
MaxAllowed |> DynObj.setValueOpt autoRangeOptions "maxallowed"
59-
MinAllowed |> DynObj.setValueOpt autoRangeOptions "minallowed"
60-
61-
autoRangeOptions)
55+
autoRangeOptions
56+
|> DynObj.withOptionalProperty "clipmax" ClipMax
57+
|> DynObj.withOptionalProperty "clipmin" ClipMin
58+
|> DynObj.withOptionalProperty "include" Include
59+
|> DynObj.withOptionalProperty "maxallowed" MaxAllowed
60+
|> DynObj.withOptionalProperty "minallowed" MinAllowed
61+
)

Diff for: src/Plotly.NET/CommonAbstractions/ColorBar.fs

+48-48
Original file line numberDiff line numberDiff line change
@@ -254,52 +254,52 @@ type ColorBar() =
254254
) =
255255

256256
(fun (colorBar: ColorBar) ->
257+
colorBar
258+
|> DynObj.withOptionalProperty "bgcolor" BGColor
259+
|> DynObj.withOptionalProperty "bordercolor" BorderColor
260+
|> DynObj.withOptionalProperty "borderwidth" BorderWidth
261+
|> DynObj.withOptionalProperty "dtick" DTick
262+
|> DynObj.withOptionalPropertyBy "exponentformat" ExponentFormat StyleParam.ExponentFormat.convert
263+
|> DynObj.withOptionalProperty "labelalias" LabelAlias
264+
|> DynObj.withOptionalProperty "len" Len
265+
|> DynObj.withOptionalPropertyBy "lenmode" LenMode StyleParam.UnitMode.convert
266+
|> DynObj.withOptionalProperty "min3xponent" MinExponent
267+
|> DynObj.withOptionalProperty "nticks" NTicks
268+
|> DynObj.withOptionalPropertyBy "orientation" Orientation StyleParam.Orientation.convert
269+
|> DynObj.withOptionalProperty "outlinecolor" OutlineColor
270+
|> DynObj.withOptionalProperty "outlinewidth" OutlineWidth
271+
|> DynObj.withOptionalProperty "separatethousands" SeparateThousands
272+
|> DynObj.withOptionalPropertyBy "showexponent" ShowExponent StyleParam.ShowExponent.convert
273+
|> DynObj.withOptionalProperty "showticklabels" ShowTickLabels
274+
|> DynObj.withOptionalPropertyBy "showtickprefix" ShowTickPrefix StyleParam.ShowTickOption.convert
275+
|> DynObj.withOptionalPropertyBy "showticksuffix" ShowTickSuffix StyleParam.ShowTickOption.convert
276+
|> DynObj.withOptionalProperty "thickness" Thickness
277+
|> DynObj.withOptionalPropertyBy "thicknessmode" ThicknessMode StyleParam.UnitMode.convert
278+
|> DynObj.withOptionalProperty "tick0" Tick0
279+
|> DynObj.withOptionalProperty "tickangle" TickAngle
280+
|> DynObj.withOptionalProperty "tickcolor" TickColor
281+
|> DynObj.withOptionalProperty "tickfont" TickFont
282+
|> DynObj.withOptionalProperty "tickformat" TickFormat
283+
|> DynObj.withOptionalProperty "tickformatstops" TickFormatStops
284+
|> DynObj.withOptionalPropertyBy "ticklabeloverflow" TickLabelOverflow StyleParam.TickLabelOverflow.convert
285+
|> DynObj.withOptionalPropertyBy "ticklabelposition" TickLabelPosition StyleParam.TickLabelPosition.convert
286+
|> DynObj.withOptionalProperty "ticklabelstep" TickLabelStep
287+
|> DynObj.withOptionalProperty "ticklen" TickLen
288+
|> DynObj.withOptionalPropertyBy "tickmode" TickMode StyleParam.TickMode.convert
289+
|> DynObj.withOptionalProperty "tickprefix" TickPrefix
290+
|> DynObj.withOptionalPropertyBy "ticks" Ticks StyleParam.TickOptions.convert
291+
|> DynObj.withOptionalProperty "ticksuffix" TickSuffix
292+
|> DynObj.withOptionalProperty "ticktext" TickText
293+
|> DynObj.withOptionalProperty "tickvals" TickVals
294+
|> DynObj.withOptionalProperty "tickwidth" TickWidth
295+
|> DynObj.withOptionalProperty "title" Title
296+
|> DynObj.withOptionalProperty "x" X
297+
|> DynObj.withOptionalPropertyBy "xanchor" XAnchor StyleParam.HorizontalAlign.convert
298+
|> DynObj.withOptionalProperty "xpad" XPad
299+
|> DynObj.withOptionalProperty "xref" XRef
300+
|> DynObj.withOptionalProperty "y" Y
301+
|> DynObj.withOptionalPropertyBy "yanchor" YAnchor StyleParam.VerticalAlign.convert
302+
|> DynObj.withOptionalProperty "ypad" YPad
303+
|> DynObj.withOptionalProperty "yref" YRef
257304

258-
BGColor |> DynObj.setValueOpt colorBar "bgcolor"
259-
BorderColor |> DynObj.setValueOpt colorBar "bordercolor"
260-
BorderWidth |> DynObj.setValueOpt colorBar "borderwidth"
261-
DTick |> DynObj.setValueOpt colorBar "dtick"
262-
ExponentFormat |> DynObj.setValueOptBy colorBar "exponentformat" StyleParam.ExponentFormat.convert
263-
LabelAlias |> DynObj.setValueOpt colorBar "labelalias"
264-
Len |> DynObj.setValueOpt colorBar "len"
265-
LenMode |> DynObj.setValueOptBy colorBar "lenmode" StyleParam.UnitMode.convert
266-
MinExponent |> DynObj.setValueOpt colorBar "min3xponent"
267-
NTicks |> DynObj.setValueOpt colorBar "nticks"
268-
Orientation |> DynObj.setValueOptBy colorBar "orientation" StyleParam.Orientation.convert
269-
OutlineColor |> DynObj.setValueOpt colorBar "outlinecolor"
270-
OutlineWidth |> DynObj.setValueOpt colorBar "outlinewidth"
271-
SeparateThousands |> DynObj.setValueOpt colorBar "separatethousands"
272-
ShowExponent |> DynObj.setValueOptBy colorBar "showexponent" StyleParam.ShowExponent.convert
273-
ShowTickLabels |> DynObj.setValueOpt colorBar "showticklabels"
274-
ShowTickPrefix |> DynObj.setValueOptBy colorBar "showtickprefix" StyleParam.ShowTickOption.convert
275-
ShowTickSuffix |> DynObj.setValueOptBy colorBar "showticksuffix" StyleParam.ShowTickOption.convert
276-
Thickness |> DynObj.setValueOpt colorBar "thickness"
277-
ThicknessMode |> DynObj.setValueOptBy colorBar "thicknessmode" StyleParam.UnitMode.convert
278-
Tick0 |> DynObj.setValueOpt colorBar "tick0"
279-
TickAngle |> DynObj.setValueOpt colorBar "tickangle"
280-
TickColor |> DynObj.setValueOpt colorBar "tickcolor"
281-
TickFont |> DynObj.setValueOpt colorBar "tickfont"
282-
TickFormat |> DynObj.setValueOpt colorBar "tickformat"
283-
TickFormatStops |> DynObj.setValueOpt colorBar "tickformatstops"
284-
TickLabelOverflow |> DynObj.setValueOptBy colorBar "ticklabeloverflow" StyleParam.TickLabelOverflow.convert
285-
TickLabelPosition |> DynObj.setValueOptBy colorBar "ticklabelposition" StyleParam.TickLabelPosition.convert
286-
TickLabelStep |> DynObj.setValueOpt colorBar "ticklabelstep"
287-
TickLen |> DynObj.setValueOpt colorBar "ticklen"
288-
TickMode |> DynObj.setValueOptBy colorBar "tickmode" StyleParam.TickMode.convert
289-
TickPrefix |> DynObj.setValueOpt colorBar "tickprefix"
290-
Ticks |> DynObj.setValueOptBy colorBar "ticks" StyleParam.TickOptions.convert
291-
TickSuffix |> DynObj.setValueOpt colorBar "ticksuffix"
292-
TickText |> DynObj.setValueOpt colorBar "ticktext"
293-
TickVals |> DynObj.setValueOpt colorBar "tickvals"
294-
TickWidth |> DynObj.setValueOpt colorBar "tickwidth"
295-
Title |> DynObj.setValueOpt colorBar "title"
296-
X |> DynObj.setValueOpt colorBar "x"
297-
XAnchor |> DynObj.setValueOptBy colorBar "xanchor" StyleParam.HorizontalAlign.convert
298-
XPad |> DynObj.setValueOpt colorBar "xpad"
299-
XRef |> DynObj.setValueOpt colorBar "xref"
300-
Y |> DynObj.setValueOpt colorBar "y"
301-
YAnchor |> DynObj.setValueOptBy colorBar "yanchor" StyleParam.VerticalAlign.convert
302-
YPad |> DynObj.setValueOpt colorBar "ypad"
303-
YRef |> DynObj.setValueOpt colorBar "yref"
304-
305-
colorBar)
305+
)

Diff for: src/Plotly.NET/CommonAbstractions/Font.fs

+5-6
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,8 @@ type Font() =
2626
[<Optional; DefaultParameterValue(null)>] ?Color: Color
2727
) =
2828
(fun (font: Font) ->
29-
30-
Family |> DynObj.setValueOptBy font "family" StyleParam.FontFamily.toString
31-
Size |> DynObj.setValueOpt font "size"
32-
Color |> DynObj.setValueOpt font "color"
33-
34-
font)
29+
font
30+
|> DynObj.withOptionalPropertyBy "family" Family StyleParam.FontFamily.toString
31+
|> DynObj.withOptionalProperty "size" Size
32+
|> DynObj.withOptionalProperty "color" Color
33+
)

Diff for: src/Plotly.NET/CommonAbstractions/Line.fs

+22-21
Original file line numberDiff line numberDiff line change
@@ -125,25 +125,26 @@ type Line() =
125125
[<Optional; DefaultParameterValue(null)>] ?OutlierWidth: float
126126
) =
127127
(fun (line: Line) ->
128-
BackOff |> DynObj.setValueOptBy line "backoff" StyleParam.BackOff.convert
129-
Color |> DynObj.setValueOpt line "color"
130-
(Width, MultiWidth) |> DynObj.setSingleOrMultiOpt line "width"
131-
Shape |> DynObj.setValueOptBy line "shape" StyleParam.Shape.convert
132-
Smoothing |> DynObj.setValueOpt line "smoothing"
133-
Dash |> DynObj.setValueOptBy line "dash" StyleParam.DrawingStyle.convert
134-
OutlierColor |> DynObj.setValueOpt line "outliercolor"
135-
OutlierWidth |> DynObj.setValueOpt line "outlierwidth"
136-
AutoColorScale |> DynObj.setValueOpt line "autocolorscale"
137-
CAuto |> DynObj.setValueOpt line "cauto"
138-
CMax |> DynObj.setValueOpt line "cmax"
139-
CMid |> DynObj.setValueOpt line "cmid"
140-
CMin |> DynObj.setValueOpt line "cmin"
141-
Color |> DynObj.setValueOpt line "color"
142-
ColorAxis |> DynObj.setValueOptBy line "coloraxis" StyleParam.SubPlotId.convert
143-
Colorscale |> DynObj.setValueOptBy line "colorscale" StyleParam.Colorscale.convert
144-
ReverseScale |> DynObj.setValueOpt line "reversescale"
145-
ShowScale |> DynObj.setValueOpt line "showscale"
146-
ColorBar |> DynObj.setValueOpt line "colorbar"
147-
Simplify |> DynObj.setValueOpt line "simplify"
128+
line
129+
|> DynObj.withOptionalPropertyBy "backoff" BackOff StyleParam.BackOff.convert
130+
|> DynObj.withOptionalProperty "color" Color
131+
|> DynObj.withOptionalSingleOrMultiProperty "width" (Width, MultiWidth)
132+
|> DynObj.withOptionalPropertyBy "shape" Shape StyleParam.Shape.convert
133+
|> DynObj.withOptionalProperty "smoothing" Smoothing
134+
|> DynObj.withOptionalPropertyBy "dash" Dash StyleParam.DrawingStyle.convert
135+
|> DynObj.withOptionalProperty "outliercolor" OutlierColor
136+
|> DynObj.withOptionalProperty "outlierwidth" OutlierWidth
137+
|> DynObj.withOptionalProperty "autocolorscale" AutoColorScale
138+
|> DynObj.withOptionalProperty "cauto" CAuto
139+
|> DynObj.withOptionalProperty "cmax" CMax
140+
|> DynObj.withOptionalProperty "cmid" CMid
141+
|> DynObj.withOptionalProperty "cmin" CMin
142+
|> DynObj.withOptionalProperty "color" Color
143+
|> DynObj.withOptionalPropertyBy "coloraxis" ColorAxis StyleParam.SubPlotId.convert
144+
|> DynObj.withOptionalPropertyBy "colorscale" Colorscale StyleParam.Colorscale.convert
145+
|> DynObj.withOptionalProperty "reversescale" ReverseScale
146+
|> DynObj.withOptionalProperty "showscale" ShowScale
147+
|> DynObj.withOptionalProperty "colorbar" ColorBar
148+
|> DynObj.withOptionalProperty "simplify" Simplify
148149

149-
line)
150+
)

Diff for: src/Plotly.NET/CommonAbstractions/Padding.fs

+6-5
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ type Padding() =
3737
[<Optional; DefaultParameterValue(null)>] ?T: int
3838
) =
3939
(fun (padding: Padding) ->
40-
B |> DynObj.setValueOpt padding "b"
41-
L |> DynObj.setValueOpt padding "l"
42-
R |> DynObj.setValueOpt padding "r"
43-
T |> DynObj.setValueOpt padding "t"
44-
padding)
40+
padding
41+
|> DynObj.withOptionalProperty "b" B
42+
|> DynObj.withOptionalProperty "l" L
43+
|> DynObj.withOptionalProperty "r" R
44+
|> DynObj.withOptionalProperty "t" T
45+
)

Diff for: src/Plotly.NET/CommonAbstractions/TickFormatStop.fs

+7-8
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ type TickFormatStop() =
3535
) =
3636
(fun (tickFormatStop: TickFormatStop) ->
3737

38-
Enabled |> DynObj.setValueOpt tickFormatStop "enabled"
39-
DTickRange |> DynObj.setValueOpt tickFormatStop "dtickrange"
40-
Value |> DynObj.setValueOpt tickFormatStop "value"
41-
Name |> DynObj.setValueOpt tickFormatStop "name"
42-
TemplateItemName |> DynObj.setValueOpt tickFormatStop "templateitemname"
43-
44-
45-
tickFormatStop)
38+
tickFormatStop
39+
|> DynObj.withOptionalProperty "enabled" Enabled
40+
|> DynObj.withOptionalProperty "dtickrange" DTickRange
41+
|> DynObj.withOptionalProperty "value" Value
42+
|> DynObj.withOptionalProperty "name" Name
43+
|> DynObj.withOptionalProperty "templateitemname" TemplateItemName
44+
)

Diff for: src/Plotly.NET/CommonAbstractions/Title.fs

+15-16
Original file line numberDiff line numberDiff line change
@@ -87,19 +87,18 @@ type Title() =
8787
// For colorbar titles
8888
[<Optional; DefaultParameterValue(null)>] ?Side: StyleParam.Side
8989
) =
90-
(fun (title: Title) ->
91-
92-
Text |> DynObj.setValueOpt title "text"
93-
Font |> DynObj.setValueOpt title "font"
94-
AutoMargin |> DynObj.setValueOpt title "automargin"
95-
Pad |> DynObj.setValueOpt title "pad"
96-
X |> DynObj.setValueOpt title "x"
97-
XAnchor |> DynObj.setValueOptBy title "xanchor" StyleParam.XAnchorPosition.convert
98-
XRef |> DynObj.setValueOpt title "xref"
99-
Y |> DynObj.setValueOpt title "y"
100-
YAnchor |> DynObj.setValueOptBy title "yanchor" StyleParam.YAnchorPosition.convert
101-
YRef |> DynObj.setValueOpt title "yref"
102-
Standoff |> DynObj.setValueOpt title "standoff"
103-
Side |> DynObj.setValueOptBy title "side" StyleParam.Side.convert
104-
105-
title)
90+
(fun (title: Title) ->
91+
title
92+
|> DynObj.withOptionalProperty "text" Text
93+
|> DynObj.withOptionalProperty "font" Font
94+
|> DynObj.withOptionalProperty "automargin" AutoMargin
95+
|> DynObj.withOptionalProperty "pad" Pad
96+
|> DynObj.withOptionalProperty "x" X
97+
|> DynObj.withOptionalPropertyBy "xanchor" XAnchor StyleParam.XAnchorPosition.convert
98+
|> DynObj.withOptionalProperty "xref" XRef
99+
|> DynObj.withOptionalProperty "y" Y
100+
|> DynObj.withOptionalPropertyBy "yanchor" YAnchor StyleParam.YAnchorPosition.convert
101+
|> DynObj.withOptionalProperty "yref" YRef
102+
|> DynObj.withOptionalProperty "standoff" Standoff
103+
|> DynObj.withOptionalPropertyBy "side" Side StyleParam.Side.convert
104+
)

0 commit comments

Comments
 (0)