Skip to content

Commit

Permalink
plotlyjs v2.13: Add flaglist options including "left", "right", "top"…
Browse files Browse the repository at this point in the history
…, "bottom", "width" and "height"

to control the direction of automargin on cartesian axes (plotly/plotly.js#6193)
  • Loading branch information
kMutagene committed Feb 6, 2023
1 parent bda17d2 commit 5c7cadd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
26 changes: 26 additions & 0 deletions src/Plotly.NET/CommonAbstractions/StyleParams.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,32 @@ module StyleParam =
override this.ToString() = this |> ArrowSide.toString
member this.Convert() = this |> ArrowSide.convert

[<RequireQualifiedAccess>]
type TickAutoMargin =
| Height
| Width
| Left
| Right
| Top
| Bottom
| All
| Custom of seq<TickAutoMargin>

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

[<RequireQualifiedAccess>]
type AnnotationAlignment =
| Left
Expand Down
8 changes: 4 additions & 4 deletions src/Plotly.NET/Layout/ObjectAbstractions/Common/LinearAxis.fs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ type LinearAxis() =
[<Optional; DefaultParameterValue(null)>] ?TickWidth: int,
[<Optional; DefaultParameterValue(null)>] ?TickColor: Color,
[<Optional; DefaultParameterValue(null)>] ?ShowTickLabels: bool,
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: bool,
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: StyleParam.TickAutoMargin,
[<Optional; DefaultParameterValue(null)>] ?ShowSpikes: bool,
[<Optional; DefaultParameterValue(null)>] ?SpikeColor: Color,
[<Optional; DefaultParameterValue(null)>] ?SpikeThickness: int,
Expand Down Expand Up @@ -371,7 +371,7 @@ type LinearAxis() =
[<Optional; DefaultParameterValue(null)>] ?TickWidth: int,
[<Optional; DefaultParameterValue(null)>] ?TickColor: Color,
[<Optional; DefaultParameterValue(null)>] ?ShowTickLabels: bool,
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: bool,
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: StyleParam.TickAutoMargin,
[<Optional; DefaultParameterValue(null)>] ?ShowSpikes: bool,
[<Optional; DefaultParameterValue(null)>] ?SpikeColor: Color,
[<Optional; DefaultParameterValue(null)>] ?SpikeThickness: int,
Expand Down Expand Up @@ -889,7 +889,7 @@ type LinearAxis() =
[<Optional; DefaultParameterValue(null)>] ?TickWidth: int,
[<Optional; DefaultParameterValue(null)>] ?TickColor: Color,
[<Optional; DefaultParameterValue(null)>] ?ShowTickLabels: bool,
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: bool,
[<Optional; DefaultParameterValue(null)>] ?AutoMargin: StyleParam.TickAutoMargin,
[<Optional; DefaultParameterValue(null)>] ?ShowSpikes: bool,
[<Optional; DefaultParameterValue(null)>] ?SpikeColor: Color,
[<Optional; DefaultParameterValue(null)>] ?SpikeThickness: int,
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions src/Plotly.NET/Templates/ChartTemplates.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 5c7cadd

Please sign in to comment.