Skip to content

Commit b9dffc3

Browse files
committed
plotlyjs v2.15: Add entrywidth and entrywidthmode to legend (plotly/plotly.js#6202), reflect changes in Chart.withLayoutStyle
1 parent 9be3f62 commit b9dffc3

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

src/Plotly.NET/ChartAPI/Chart.fs

+6-3
Original file line numberDiff line numberDiff line change
@@ -2565,7 +2565,9 @@ type Chart =
25652565
(
25662566
[<Optional; DefaultParameterValue(null)>] ?BGColor: Color,
25672567
[<Optional; DefaultParameterValue(null)>] ?BorderColor: Color,
2568-
[<Optional; DefaultParameterValue(null)>] ?Borderwidth: float,
2568+
[<Optional; DefaultParameterValue(null)>] ?BorderWidth: float,
2569+
[<Optional; DefaultParameterValue(null)>] ?EntryWidth: float,
2570+
[<Optional; DefaultParameterValue(null)>] ?EntryWidthMode: StyleParam.EntryWidthMode,
25692571
[<Optional; DefaultParameterValue(null)>] ?Font: Font,
25702572
[<Optional; DefaultParameterValue(null)>] ?GroupClick: StyleParam.TraceGroupClickOptions,
25712573
[<Optional; DefaultParameterValue(null)>] ?GroupTitleFont: Font,
@@ -2589,7 +2591,9 @@ type Chart =
25892591
Legend.init (
25902592
?BGColor = BGColor,
25912593
?BorderColor = BorderColor,
2592-
?Borderwidth = Borderwidth,
2594+
?BorderWidth = BorderWidth,
2595+
?EntryWidth = EntryWidth,
2596+
?EntryWidthMode = EntryWidthMode,
25932597
?Font = Font,
25942598
?GroupClick = GroupClick,
25952599
?GroupTitleFont = GroupTitleFont,
@@ -2607,7 +2611,6 @@ type Chart =
26072611
?XAnchor = XAnchor,
26082612
?Y = Y,
26092613
?YAnchor = YAnchor
2610-
26112614
)
26122615

26132616
ch |> Chart.withLegend legend)

src/Plotly.NET/CommonAbstractions/StyleParams.fs

+15
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,21 @@ module StyleParam =
10691069
// #E#
10701070
//--------------------------
10711071

1072+
[<RequireQualifiedAccess>]
1073+
type EntryWidthMode =
1074+
| Fraction
1075+
| Pixels
1076+
1077+
static member toString =
1078+
function
1079+
| Fraction -> "fraction"
1080+
| Pixels -> "pixels"
1081+
1082+
1083+
static member convert = EntryWidthMode.toString >> box
1084+
override this.ToString() = this |> EntryWidthMode.toString
1085+
member this.Convert() = this |> EntryWidthMode.convert
1086+
10721087
[<RequireQualifiedAccess>]
10731088
type ErrorType =
10741089
| Percent

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

+16-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ type Legend() =
1414
/// </summary>
1515
/// <param name="BGColor">Sets the legend background color. Defaults to `layout.paper_bgcolor`.</param>
1616
/// <param name="BorderColor">Sets the color of the border enclosing the legend.</param>
17+
/// <param name="EntryWidth">Sets the width (in px or fraction) of the legend. Use 0 to size the entry based on the text width, when `entrywidthmode` is set to "pixels".</param>
18+
/// <param name="EntryWidthMode">Determines what entrywidth means.</param>
1719
/// <param name="Borderwidth">Sets the width (in px) of the border enclosing the legend.</param>
1820
/// <param name="Font">Sets the font used to text the legend items.</param>
1921
/// <param name="GroupClick">Determines the behavior on legend group item click. "toggleitem" toggles the visibility of the individual item clicked on the graph. "togglegroup" toggles the visibility of all items in the same legendgroup as the item clicked on the graph.</param>
@@ -36,7 +38,9 @@ type Legend() =
3638
(
3739
[<Optional; DefaultParameterValue(null)>] ?BGColor: Color,
3840
[<Optional; DefaultParameterValue(null)>] ?BorderColor: Color,
39-
[<Optional; DefaultParameterValue(null)>] ?Borderwidth: float,
41+
[<Optional; DefaultParameterValue(null)>] ?BorderWidth: float,
42+
[<Optional; DefaultParameterValue(null)>] ?EntryWidth: float,
43+
[<Optional; DefaultParameterValue(null)>] ?EntryWidthMode: StyleParam.EntryWidthMode,
4044
[<Optional; DefaultParameterValue(null)>] ?Font: Font,
4145
[<Optional; DefaultParameterValue(null)>] ?GroupClick: StyleParam.TraceGroupClickOptions,
4246
[<Optional; DefaultParameterValue(null)>] ?GroupTitleFont: Font,
@@ -59,7 +63,9 @@ type Legend() =
5963
|> Legend.style (
6064
?BGColor = BGColor,
6165
?BorderColor = BorderColor,
62-
?Borderwidth = Borderwidth,
66+
?BorderWidth = BorderWidth,
67+
?EntryWidth = EntryWidth,
68+
?EntryWidthMode = EntryWidthMode,
6369
?Font = Font,
6470
?GroupClick = GroupClick,
6571
?GroupTitleFont = GroupTitleFont,
@@ -85,6 +91,8 @@ type Legend() =
8591
/// <param name="BGColor">Sets the legend background color. Defaults to `layout.paper_bgcolor`.</param>
8692
/// <param name="BorderColor">Sets the color of the border enclosing the legend.</param>
8793
/// <param name="Borderwidth">Sets the width (in px) of the border enclosing the legend.</param>
94+
/// <param name="EntryWidth">Sets the width (in px or fraction) of the legend. Use 0 to size the entry based on the text width, when `entrywidthmode` is set to "pixels".</param>
95+
/// <param name="EntryWidthMode">Determines what entrywidth means.</param>
8896
/// <param name="Font">Sets the font used to text the legend items.</param>
8997
/// <param name="GroupClick">Determines the behavior on legend group item click. "toggleitem" toggles the visibility of the individual item clicked on the graph. "togglegroup" toggles the visibility of all items in the same legendgroup as the item clicked on the graph.</param>
9098
/// <param name="GroupTitleFont">Sets the font for group titles in legend. Defaults to `legend.font` with its size increased about 10%.</param>
@@ -106,7 +114,9 @@ type Legend() =
106114
(
107115
[<Optional; DefaultParameterValue(null)>] ?BGColor: Color,
108116
[<Optional; DefaultParameterValue(null)>] ?BorderColor: Color,
109-
[<Optional; DefaultParameterValue(null)>] ?Borderwidth: float,
117+
[<Optional; DefaultParameterValue(null)>] ?BorderWidth: float,
118+
[<Optional; DefaultParameterValue(null)>] ?EntryWidth: float,
119+
[<Optional; DefaultParameterValue(null)>] ?EntryWidthMode: StyleParam.EntryWidthMode,
110120
[<Optional; DefaultParameterValue(null)>] ?Font: Font,
111121
[<Optional; DefaultParameterValue(null)>] ?GroupClick: StyleParam.TraceGroupClickOptions,
112122
[<Optional; DefaultParameterValue(null)>] ?GroupTitleFont: Font,
@@ -128,7 +138,9 @@ type Legend() =
128138
(fun (legend: Legend) ->
129139
BGColor |> DynObj.setValueOpt legend "bgcolor"
130140
BorderColor |> DynObj.setValueOpt legend "bordercolor"
131-
Borderwidth |> DynObj.setValueOpt legend "font"
141+
BorderWidth |> DynObj.setValueOpt legend "font"
142+
EntryWidth|> DynObj.setValueOpt legend "entrywidth"
143+
EntryWidthMode|> DynObj.setValueOptBy legend "entrywidthmode" StyleParam.EntryWidthMode.convert
132144
Font |> DynObj.setValueOpt legend "borderwidth"
133145
GroupClick |> DynObj.setValueOptBy legend "groupclick" StyleParam.TraceGroupClickOptions.convert
134146
GroupTitleFont |> DynObj.setValueOpt legend "grouptitlefont"

0 commit comments

Comments
 (0)