Skip to content

Commit 2aef860

Browse files
committed
#269: box all boolean style params correctly
1 parent b727966 commit 2aef860

File tree

3 files changed

+61
-85
lines changed

3 files changed

+61
-85
lines changed

src/Plotly.NET/CommonAbstractions/StyleParams.fs

Lines changed: 59 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -89,14 +89,12 @@ module StyleParam =
8989
| False
9090
| Reversed
9191

92-
static member toString =
92+
static member convert =
9393
function
94-
| True -> "true"
95-
| False -> "false"
96-
| Reversed -> "reversed"
94+
| True -> box true
95+
| False -> box false
96+
| Reversed -> box "reversed"
9797

98-
static member convert = AutoRange.toString >> box
99-
override this.ToString() = this |> AutoRange.toString
10098
member this.Convert() = this |> AutoRange.convert
10199

102100
/// Sets the axis type. By default (Auto), plotly attempts to determined the axis type by looking into the data of the traces that referenced the axis in question.
@@ -301,18 +299,16 @@ module StyleParam =
301299
type BoxPoints =
302300
| Outliers
303301
| All
304-
| Suspectedoutliers
302+
| SuspectedOutliers
305303
| False
306304

307-
static member toString =
305+
static member convert =
308306
function
309-
| Outliers -> "outliers"
310-
| All -> "all"
311-
| Suspectedoutliers -> "suspectedoutliers"
312-
| False -> "false"
307+
| Outliers -> box "outliers"
308+
| All -> box "all"
309+
| SuspectedOutliers -> box "suspectedoutliers"
310+
| False -> box false
313311

314-
static member convert = BoxPoints.toString >> box
315-
override this.ToString() = this |> BoxPoints.toString
316312
member this.Convert() = this |> BoxPoints.convert
317313

318314

@@ -589,14 +585,12 @@ module StyleParam =
589585
| OnOff
590586
| OnOut
591587

592-
static member toString =
588+
static member convert =
593589
function
594-
| False -> "false"
595-
| OnOff -> "onoff"
596-
| OnOut -> "onout"
590+
| False -> box false
591+
| OnOff -> box "onoff"
592+
| OnOut -> box "onout"
597593

598-
static member convert = ClickToShow.toString >> box
599-
override this.ToString() = this |> ClickToShow.toString
600594
member this.Convert() = this |> ClickToShow.convert
601595

602596
[<RequireQualifiedAccess>]
@@ -936,23 +930,21 @@ module StyleParam =
936930
| TurnTable
937931
| False
938932

939-
static member toString =
933+
static member convert =
940934
function
941-
| Zoom -> "zoom"
942-
| Pan -> "pan"
943-
| Select -> "select"
944-
| Lasso -> "lasso"
945-
| DrawClosedPath -> "drawclosedpath"
946-
| DrawOpenPath -> "drawopenpath"
947-
| DrawLine -> "drawline"
948-
| DrawRect -> "drawrect"
949-
| DrawCircle -> "drawcircle"
950-
| Orbit -> "orbit"
951-
| TurnTable -> "turntable"
952-
| False -> "False"
935+
| Zoom -> box "zoom"
936+
| Pan -> box "pan"
937+
| Select -> box "select"
938+
| Lasso -> box "lasso"
939+
| DrawClosedPath -> box "drawclosedpath"
940+
| DrawOpenPath -> box "drawopenpath"
941+
| DrawLine -> box "drawline"
942+
| DrawRect -> box "drawrect"
943+
| DrawCircle -> box "drawcircle"
944+
| Orbit -> box "orbit"
945+
| TurnTable -> box "turntable"
946+
| False -> box false
953947

954-
static member convert = DragMode.toString >> box
955-
override this.ToString() = this |> DragMode.toString
956948
member this.Convert() = this |> DragMode.convert
957949

958950
/// Sets the Delaunay axis, which is the axis that is perpendicular to the surface of the Delaunay triangulation.
@@ -1191,14 +1183,12 @@ module StyleParam =
11911183
| Locations
11921184
| GeoJson
11931185

1194-
static member toString =
1186+
static member convert =
11951187
function
1196-
| False -> "false"
1197-
| Locations -> "locations"
1198-
| GeoJson -> "geojson"
1188+
| False -> box false
1189+
| Locations -> box "locations"
1190+
| GeoJson -> box "geojson"
11991191

1200-
static member convert = GeoFitBounds.toString >> box
1201-
override this.ToString() = this |> GeoFitBounds.toString
12021192
member this.Convert() = this |> GeoFitBounds.convert
12031193

12041194
///Used for the Layout.geo field. Sets the resolution of the base layers. The values have units of km/mm e.g. 110 corresponds to a scale ratio of 1:110,000,000.
@@ -1416,16 +1406,18 @@ module StyleParam =
14161406
| X
14171407
| Y
14181408
| False
1409+
| XUnified
1410+
| YUnified
14191411

1420-
static member toString =
1412+
static member convert =
14211413
function
1422-
| Closest -> "closest"
1423-
| X -> "x"
1424-
| Y -> "y"
1425-
| False -> "false"
1414+
| Closest -> box "closest"
1415+
| X -> box "x"
1416+
| Y -> box "y"
1417+
| False -> box false
1418+
| XUnified -> box "x unified"
1419+
| YUnified -> box "y unified"
14261420

1427-
static member convert = HoverMode.toString >> box
1428-
override this.ToString() = this |> HoverMode.toString
14291421
member this.Convert() = this |> HoverMode.convert
14301422

14311423
[<RequireQualifiedAccess>]
@@ -1898,16 +1890,14 @@ module StyleParam =
18981890
| All
18991891
| AllTicks
19001892

1901-
static member toString =
1893+
static member convert =
19021894
function
1903-
| True -> "true"
1904-
| Ticks -> "ticks"
1905-
| False -> "false"
1906-
| All -> "all"
1907-
| AllTicks -> "allticks"
1895+
| True -> box true
1896+
| Ticks -> box "ticks"
1897+
| False -> box false
1898+
| All -> box "all"
1899+
| AllTicks -> box "allticks"
19081900

1909-
static member convert = Mirror.toString >> box
1910-
override this.ToString() = this |> Mirror.toString
19111901
member this.Convert() = this |> Mirror.convert
19121902

19131903
// | "lines", "markers", "text" joined with a "+" OR "none".
@@ -2666,14 +2656,12 @@ module StyleParam =
26662656
| Best
26672657
| Fast
26682658

2669-
static member toString =
2659+
static member convert =
26702660
function
2671-
| False -> "false"
2672-
| Best -> "best"
2673-
| Fast -> "fast"
2661+
| False -> box false
2662+
| Best -> box "best"
2663+
| Fast -> box "fast"
26742664

2675-
static member convert = SmoothAlg.toString >> box
2676-
override this.ToString() = this |> SmoothAlg.toString
26772665
member this.Convert() = this |> SmoothAlg.convert
26782666

26792667
/// Determines the drawing mode for the spike line
@@ -3136,14 +3124,12 @@ module StyleParam =
31363124
| ToggleOthers
31373125
| False
31383126

3139-
static member toString =
3127+
static member convert =
31403128
function
3141-
| Toggle -> "toggle"
3142-
| ToggleOthers -> "toggleothers"
3143-
| False -> "False"
3129+
| Toggle -> box "toggle"
3130+
| ToggleOthers -> box "toggleothers"
3131+
| False -> box false
31443132

3145-
static member convert = TraceItemClickOptions.toString >> box
3146-
override this.ToString() = this |> TraceItemClickOptions.toString
31473133
member this.Convert() = this |> TraceItemClickOptions.convert
31483134

31493135
[<RequireQualifiedAccess>]
@@ -3309,14 +3295,12 @@ module StyleParam =
33093295
| False
33103296
| Show
33113297

3312-
static member toString =
3298+
static member convert =
33133299
function
3314-
| Hide -> "hide"
3315-
| False -> "false"
3316-
| Show -> "show"
3300+
| Hide -> box "hide"
3301+
| False -> box false
3302+
| Show -> box "show"
33173303

3318-
static member convert = UniformTextMode.toString >> box
3319-
override this.ToString() = this |> UniformTextMode.toString
33203304
member this.Convert() = this |> UniformTextMode.convert
33213305

33223306
//--------------------------
@@ -3360,20 +3344,12 @@ module StyleParam =
33603344
| False
33613345
| LegendOnly
33623346

3363-
static member toObject =
3347+
static member convert =
33643348
function
33653349
| True -> box (true)
33663350
| False -> box (false)
33673351
| LegendOnly -> box ("legendonly")
33683352

3369-
static member toString =
3370-
function
3371-
| True -> "true"
3372-
| False -> "false"
3373-
| LegendOnly -> "legendonly"
3374-
3375-
static member convert = Visible.toObject >> box
3376-
override this.ToString() = this |> Visible.toString
33773353
member this.Convert() = this |> Visible.convert
33783354

33793355
[<RequireQualifiedAccess>]

src/Plotly.NET/Traces/Trace.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ type TraceStyle() =
303303
(fun (trace: ('T :> Trace)) ->
304304

305305
Name |> DynObj.setValueOpt trace "name"
306-
Visible |> DynObj.setValueOptBy trace "visible" StyleParam.Visible.toObject
306+
Visible |> DynObj.setValueOptBy trace "visible" StyleParam.Visible.convert
307307
ShowLegend |> DynObj.setValueOpt trace "showlegend"
308308
LegendRank |> DynObj.setValueOpt trace "legendrank"
309309
LegendGroup |> DynObj.setValueOpt trace "legendgroup"

tests/Plotly.NET.Tests/LayoutObjects/LinearAxis.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ let ``LinearAxis tests`` =
9696
fullAxis |> createJsonFieldTest "title" "{\"text\":\"Hi\"}"
9797
fullAxis |> createJsonFieldTest "type" "\"log\""
9898
fullAxis |> createJsonFieldTest "autotypenumbers" "\"strict\""
99-
fullAxis |> createJsonFieldTest "autorange" "\"true\""
99+
fullAxis |> createJsonFieldTest "autorange" "true"
100100
fullAxis |> createJsonFieldTest "rangemode" "\"normal\""
101101
fullAxis |> createJsonFieldTest "range" "[-1.0,1.0]"
102102
fullAxis |> createJsonFieldTest "fixedrange" "true"

0 commit comments

Comments
 (0)