Skip to content

Commit 5c7cadd

Browse files
committed
plotlyjs v2.13: Add flaglist options including "left", "right", "top", "bottom", "width" and "height"
to control the direction of automargin on cartesian axes (plotly/plotly.js#6193)
1 parent bda17d2 commit 5c7cadd

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

src/Plotly.NET/CommonAbstractions/StyleParams.fs

+26
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,32 @@ module StyleParam =
3131
override this.ToString() = this |> ArrowSide.toString
3232
member this.Convert() = this |> ArrowSide.convert
3333

34+
[<RequireQualifiedAccess>]
35+
type TickAutoMargin =
36+
| Height
37+
| Width
38+
| Left
39+
| Right
40+
| Top
41+
| Bottom
42+
| All
43+
| Custom of seq<TickAutoMargin>
44+
45+
static member toString =
46+
function
47+
| Height -> "height"
48+
| Width -> "width"
49+
| Left -> "left"
50+
| Right -> "right"
51+
| Top -> "top"
52+
| Bottom -> "bottom"
53+
| All -> "height+width+left+right+top+bottom"
54+
| Custom s -> s |> Seq.map (fun a -> a |> TickAutoMargin.toString) |> String.concat "+"
55+
56+
static member convert = TickAutoMargin.toString >> box
57+
override this.ToString() = this |> TickAutoMargin.toString
58+
member this.Convert() = this |> TickAutoMargin.convert
59+
3460
[<RequireQualifiedAccess>]
3561
type AnnotationAlignment =
3662
| Left

src/Plotly.NET/Layout/ObjectAbstractions/Common/LinearAxis.fs

+4-4
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ type LinearAxis() =
126126
[<Optional; DefaultParameterValue(null)>] ?TickWidth: int,
127127
[<Optional; DefaultParameterValue(null)>] ?TickColor: Color,
128128
[<Optional; DefaultParameterValue(null)>] ?ShowTickLabels: bool,
129-
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: bool,
129+
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: StyleParam.TickAutoMargin,
130130
[<Optional; DefaultParameterValue(null)>] ?ShowSpikes: bool,
131131
[<Optional; DefaultParameterValue(null)>] ?SpikeColor: Color,
132132
[<Optional; DefaultParameterValue(null)>] ?SpikeThickness: int,
@@ -371,7 +371,7 @@ type LinearAxis() =
371371
[<Optional; DefaultParameterValue(null)>] ?TickWidth: int,
372372
[<Optional; DefaultParameterValue(null)>] ?TickColor: Color,
373373
[<Optional; DefaultParameterValue(null)>] ?ShowTickLabels: bool,
374-
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: bool,
374+
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: StyleParam.TickAutoMargin,
375375
[<Optional; DefaultParameterValue(null)>] ?ShowSpikes: bool,
376376
[<Optional; DefaultParameterValue(null)>] ?SpikeColor: Color,
377377
[<Optional; DefaultParameterValue(null)>] ?SpikeThickness: int,
@@ -889,7 +889,7 @@ type LinearAxis() =
889889
[<Optional; DefaultParameterValue(null)>] ?TickWidth: int,
890890
[<Optional; DefaultParameterValue(null)>] ?TickColor: Color,
891891
[<Optional; DefaultParameterValue(null)>] ?ShowTickLabels: bool,
892-
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: bool,
892+
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: StyleParam.TickAutoMargin,
893893
[<Optional; DefaultParameterValue(null)>] ?ShowSpikes: bool,
894894
[<Optional; DefaultParameterValue(null)>] ?SpikeColor: Color,
895895
[<Optional; DefaultParameterValue(null)>] ?SpikeThickness: int,
@@ -989,7 +989,7 @@ type LinearAxis() =
989989
TickWidth |> DynObj.setValueOpt axis "tickwidth"
990990
TickColor |> DynObj.setValueOpt axis "tickcolor"
991991
ShowTickLabels |> DynObj.setValueOpt axis "showticklabels"
992-
AutoMargin |> DynObj.setValueOpt axis "automargin"
992+
AutoMargin |> DynObj.setValueOptBy axis "automargin" StyleParam.TickAutoMargin.convert
993993
ShowSpikes |> DynObj.setValueOpt axis "showspikes"
994994
SpikeColor |> DynObj.setValueOpt axis "spikecolor"
995995
SpikeThickness |> DynObj.setValueOpt axis "spikethickness"

src/Plotly.NET/Templates/ChartTemplates.fs

+2-2
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ module ChartTemplates =
322322
|> Layout.updateLinearAxisById (
323323
StyleParam.SubPlotId.XAxis 1,
324324
LinearAxis.init (
325-
AutoMargin = true,
325+
AutoMargin = StyleParam.TickAutoMargin.All,
326326
GridColor = Color.fromKeyword White,
327327
LineColor = Color.fromKeyword White,
328328
Ticks = StyleParam.TickOptions.Empty,
@@ -334,7 +334,7 @@ module ChartTemplates =
334334
|> Layout.updateLinearAxisById (
335335
StyleParam.SubPlotId.YAxis 1,
336336
LinearAxis.init (
337-
AutoMargin = true,
337+
AutoMargin = StyleParam.TickAutoMargin.All,
338338
GridColor = Color.fromKeyword White,
339339
LineColor = Color.fromKeyword White,
340340
Ticks = StyleParam.TickOptions.Empty,

0 commit comments

Comments
 (0)