diff --git a/src/Plotly.NET/CommonAbstractions/StyleParams.fs b/src/Plotly.NET/CommonAbstractions/StyleParams.fs index aa8d02547..b9501b3a4 100644 --- a/src/Plotly.NET/CommonAbstractions/StyleParams.fs +++ b/src/Plotly.NET/CommonAbstractions/StyleParams.fs @@ -31,6 +31,32 @@ module StyleParam = override this.ToString() = this |> ArrowSide.toString member this.Convert() = this |> ArrowSide.convert + [] + type TickAutoMargin = + | Height + | Width + | Left + | Right + | Top + | Bottom + | All + | Custom of seq + + static member toString = + function + | Height -> "height" + | Width -> "width" + | Left -> "left" + | Right -> "right" + | Top -> "top" + | Bottom -> "bottom" + | All -> "height+width+left+right+top+bottom" + | Custom s -> s |> Seq.map (fun a -> a |> TickAutoMargin.toString) |> String.concat "+" + + static member convert = TickAutoMargin.toString >> box + override this.ToString() = this |> TickAutoMargin.toString + member this.Convert() = this |> TickAutoMargin.convert + [] type AnnotationAlignment = | Left diff --git a/src/Plotly.NET/Layout/ObjectAbstractions/Common/LinearAxis.fs b/src/Plotly.NET/Layout/ObjectAbstractions/Common/LinearAxis.fs index 5900babfe..3d42cdfcd 100644 --- a/src/Plotly.NET/Layout/ObjectAbstractions/Common/LinearAxis.fs +++ b/src/Plotly.NET/Layout/ObjectAbstractions/Common/LinearAxis.fs @@ -126,7 +126,7 @@ type LinearAxis() = [] ?TickWidth: int, [] ?TickColor: Color, [] ?ShowTickLabels: bool, - [] ?AutoMargin: bool, + [] ?AutoMargin: StyleParam.TickAutoMargin, [] ?ShowSpikes: bool, [] ?SpikeColor: Color, [] ?SpikeThickness: int, @@ -371,7 +371,7 @@ type LinearAxis() = [] ?TickWidth: int, [] ?TickColor: Color, [] ?ShowTickLabels: bool, - [] ?AutoMargin: bool, + [] ?AutoMargin: StyleParam.TickAutoMargin, [] ?ShowSpikes: bool, [] ?SpikeColor: Color, [] ?SpikeThickness: int, @@ -889,7 +889,7 @@ type LinearAxis() = [] ?TickWidth: int, [] ?TickColor: Color, [] ?ShowTickLabels: bool, - [] ?AutoMargin: bool, + [] ?AutoMargin: StyleParam.TickAutoMargin, [] ?ShowSpikes: bool, [] ?SpikeColor: Color, [] ?SpikeThickness: int, @@ -989,7 +989,7 @@ type LinearAxis() = TickWidth |> DynObj.setValueOpt axis "tickwidth" TickColor |> DynObj.setValueOpt axis "tickcolor" ShowTickLabels |> DynObj.setValueOpt axis "showticklabels" - AutoMargin |> DynObj.setValueOpt axis "automargin" + AutoMargin |> DynObj.setValueOptBy axis "automargin" StyleParam.TickAutoMargin.convert ShowSpikes |> DynObj.setValueOpt axis "showspikes" SpikeColor |> DynObj.setValueOpt axis "spikecolor" SpikeThickness |> DynObj.setValueOpt axis "spikethickness" diff --git a/src/Plotly.NET/Templates/ChartTemplates.fs b/src/Plotly.NET/Templates/ChartTemplates.fs index 59a18eb1c..e756700b4 100644 --- a/src/Plotly.NET/Templates/ChartTemplates.fs +++ b/src/Plotly.NET/Templates/ChartTemplates.fs @@ -322,7 +322,7 @@ module ChartTemplates = |> Layout.updateLinearAxisById ( StyleParam.SubPlotId.XAxis 1, LinearAxis.init ( - AutoMargin = true, + AutoMargin = StyleParam.TickAutoMargin.All, GridColor = Color.fromKeyword White, LineColor = Color.fromKeyword White, Ticks = StyleParam.TickOptions.Empty, @@ -334,7 +334,7 @@ module ChartTemplates = |> Layout.updateLinearAxisById ( StyleParam.SubPlotId.YAxis 1, LinearAxis.init ( - AutoMargin = true, + AutoMargin = StyleParam.TickAutoMargin.All, GridColor = Color.fromKeyword White, LineColor = Color.fromKeyword White, Ticks = StyleParam.TickOptions.Empty,