Skip to content

Commit a3e1abc

Browse files
committed
plotly.js v2.23: add xref and yref attributes for Legend and ColorBar
- add tests - add attributes to Chart API functions `withLegendStyle` and `withColorBarStyle`
1 parent 39dcefa commit a3e1abc

File tree

15 files changed

+261
-38
lines changed

15 files changed

+261
-38
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![Build and test](https://github.com/plotly/Plotly.NET/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/plotly/Plotly.NET/actions/workflows/build-and-test.yml)
55
[![](https://img.shields.io/nuget/vpre/Plotly.NET)](https://www.nuget.org/packages/Plotly.NET/)
66
[![Discord](https://img.shields.io/discord/836161044501889064?color=purple&label=Join%20our%20Discord%21&logo=discord&logoColor=white)](https://discord.gg/k3kUtFY8DB)
7-
![](https://img.shields.io/badge/supported%20plotly.js%20version-2.21.0-blue)
7+
![](https://img.shields.io/badge/supported%20plotly.js%20version-2.23.2-blue)
88
[![DOI](https://img.shields.io/badge/DOI-10.12688%2Ff1000research.123971.1-brightgreen)](https://doi.org/10.12688/f1000research.123971.1)
99

1010
### Table of contents

src/Plotly.NET/ChartAPI/Chart.fs

Lines changed: 117 additions & 15 deletions
Large diffs are not rendered by default.

src/Plotly.NET/CommonAbstractions/ColorBar.fs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ type ColorBar() =
5252
/// <param name="X">Sets the x position of the color bar (in plot fraction).</param>
5353
/// <param name="XAnchor">Sets this color bar's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the color bar.</param>
5454
/// <param name="XPad">Sets the amount of padding (in px) along the x direction.</param>
55+
/// <param name="XRef">Sets the container `x` refers to. "container" spans the entire `width` of the plot. "paper" refers to the width of the plotting area only.</param>
5556
/// <param name="Y">Sets the y position of the color bar (in plot fraction).</param>
5657
/// <param name="YAnchor">Sets this color bar's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the color bar.</param>
5758
/// <param name="YPad">Sets the amount of padding (in px) along the y direction.</param>
59+
/// <param name="YRef">Sets the container `y` refers to. "container" spans the entire `height` of the plot. "paper" refers to the height of the plotting area only.</param>
5860
static member init
5961
(
6062
[<Optional; DefaultParameterValue(null)>] ?BGColor: Color,
@@ -98,9 +100,11 @@ type ColorBar() =
98100
[<Optional; DefaultParameterValue(null)>] ?X: float,
99101
[<Optional; DefaultParameterValue(null)>] ?XAnchor: StyleParam.HorizontalAlign,
100102
[<Optional; DefaultParameterValue(null)>] ?XPad: float,
103+
[<Optional; DefaultParameterValue(null)>] ?XRef: string,
101104
[<Optional; DefaultParameterValue(null)>] ?Y: float,
102105
[<Optional; DefaultParameterValue(null)>] ?YAnchor: StyleParam.VerticalAlign,
103-
[<Optional; DefaultParameterValue(null)>] ?YPad: float
106+
[<Optional; DefaultParameterValue(null)>] ?YPad: float,
107+
[<Optional; DefaultParameterValue(null)>] ?YRef: string
104108
) =
105109
ColorBar()
106110
|> ColorBar.style (
@@ -145,9 +149,11 @@ type ColorBar() =
145149
?X = X,
146150
?XAnchor = XAnchor,
147151
?XPad = XPad,
152+
?XRef = XRef,
148153
?Y = Y,
149154
?YAnchor = YAnchor,
150-
?YPad = YPad
155+
?YPad = YPad,
156+
?YRef = YRef
151157
)
152158

153159

@@ -240,9 +246,11 @@ type ColorBar() =
240246
[<Optional; DefaultParameterValue(null)>] ?X: float,
241247
[<Optional; DefaultParameterValue(null)>] ?XAnchor: StyleParam.HorizontalAlign,
242248
[<Optional; DefaultParameterValue(null)>] ?XPad: float,
249+
[<Optional; DefaultParameterValue(null)>] ?XRef: string,
243250
[<Optional; DefaultParameterValue(null)>] ?Y: float,
244251
[<Optional; DefaultParameterValue(null)>] ?YAnchor: StyleParam.VerticalAlign,
245-
[<Optional; DefaultParameterValue(null)>] ?YPad: float
252+
[<Optional; DefaultParameterValue(null)>] ?YPad: float,
253+
[<Optional; DefaultParameterValue(null)>] ?YRef: string
246254
) =
247255

248256
(fun (colorBar: ColorBar) ->
@@ -288,8 +296,10 @@ type ColorBar() =
288296
X |> DynObj.setValueOpt colorBar "x"
289297
XAnchor |> DynObj.setValueOptBy colorBar "xanchor" StyleParam.HorizontalAlign.convert
290298
XPad |> DynObj.setValueOpt colorBar "xpad"
299+
XRef |> DynObj.setValueOpt colorBar "xref"
291300
Y |> DynObj.setValueOpt colorBar "y"
292301
YAnchor |> DynObj.setValueOptBy colorBar "yanchor" StyleParam.VerticalAlign.convert
293302
YPad |> DynObj.setValueOpt colorBar "ypad"
303+
YRef |> DynObj.setValueOpt colorBar "yref"
294304

295305
colorBar)

src/Plotly.NET/Globals.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ open Giraffe.ViewEngine
77

88
/// The plotly js version loaded from cdn in rendered html docs
99
[<Literal>]
10-
let PLOTLYJS_VERSION = "2.22.0"
10+
let PLOTLYJS_VERSION = "2.23.2"
1111

1212
[<Literal>]
1313
let SCRIPT_TEMPLATE =

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ type Legend() =
3333
/// <param name="Visible">Determines whether or not this legend is visible.</param>
3434
/// <param name="X">Sets the x position (in normalized coordinates) of the legend. Defaults to "1.02" for vertical legends and defaults to "0" for horizontal legends.</param>
3535
/// <param name="XAnchor">Sets the legend's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the legend. Value "auto" anchors legends to the right for `x` values greater than or equal to 2/3, anchors legends to the left for `x` values less than or equal to 1/3 and anchors legends with respect to their center otherwise.</param>
36+
/// <param name="XRef">Sets the container `x` refers to. "container" spans the entire `width` of the plot. "paper" refers to the width of the plotting area only.</param>
3637
/// <param name="Y">Sets the y position (in normalized coordinates) of the legend. Defaults to "1" for vertical legends, defaults to "-0.1" for horizontal legends on graphs w/o range sliders and defaults to "1.1" for horizontal legends on graph with one or multiple range sliders.</param>
3738
/// <param name="YAnchor">Sets the legend's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the legend. Value "auto" anchors legends at their bottom for `y` values less than or equal to 1/3, anchors legends to at their top for `y` values greater than or equal to 2/3 and anchors legends with respect to their middle otherwise.</param>
39+
/// <param name="YRef">Sets the container `y` refers to. "container" spans the entire `height` of the plot. "paper" refers to the height of the plotting area only.</param>
3840
static member init
3941
(
4042
[<Optional; DefaultParameterValue(null)>] ?BGColor: Color,
@@ -58,8 +60,10 @@ type Legend() =
5860
[<Optional; DefaultParameterValue(null)>] ?Visible: bool,
5961
[<Optional; DefaultParameterValue(null)>] ?X: float,
6062
[<Optional; DefaultParameterValue(null)>] ?XAnchor: StyleParam.XAnchorPosition,
63+
[<Optional; DefaultParameterValue(null)>] ?XRef: string,
6164
[<Optional; DefaultParameterValue(null)>] ?Y: float,
62-
[<Optional; DefaultParameterValue(null)>] ?YAnchor: StyleParam.YAnchorPosition
65+
[<Optional; DefaultParameterValue(null)>] ?YAnchor: StyleParam.YAnchorPosition,
66+
[<Optional; DefaultParameterValue(null)>] ?YRef: string
6367
) =
6468
Legend()
6569
|> Legend.style (
@@ -84,8 +88,10 @@ type Legend() =
8488
?Visible = Visible,
8589
?X = X,
8690
?XAnchor = XAnchor,
91+
?XRef = XRef,
8792
?Y = Y,
88-
?YAnchor = YAnchor
93+
?YAnchor = YAnchor,
94+
?YRef = YRef
8995
)
9096

9197
/// <summary>
@@ -112,8 +118,10 @@ type Legend() =
112118
/// <param name="Visible">Determines whether or not this legend is visible.</param>
113119
/// <param name="X">Sets the x position (in normalized coordinates) of the legend. Defaults to "1.02" for vertical legends and defaults to "0" for horizontal legends.</param>
114120
/// <param name="XAnchor">Sets the legend's horizontal position anchor. This anchor binds the `x` position to the "left", "center" or "right" of the legend. Value "auto" anchors legends to the right for `x` values greater than or equal to 2/3, anchors legends to the left for `x` values less than or equal to 1/3 and anchors legends with respect to their center otherwise.</param>
121+
/// <param name="XRef">Sets the container `x` refers to. "container" spans the entire `width` of the plot. "paper" refers to the width of the plotting area only.</param>
115122
/// <param name="Y">Sets the y position (in normalized coordinates) of the legend. Defaults to "1" for vertical legends, defaults to "-0.1" for horizontal legends on graphs w/o range sliders and defaults to "1.1" for horizontal legends on graph with one or multiple range sliders.</param>
116123
/// <param name="YAnchor">Sets the legend's vertical position anchor This anchor binds the `y` position to the "top", "middle" or "bottom" of the legend. Value "auto" anchors legends at their bottom for `y` values less than or equal to 1/3, anchors legends to at their top for `y` values greater than or equal to 2/3 and anchors legends with respect to their middle otherwise.</param>
124+
/// <param name="YRef">Sets the container `y` refers to. "container" spans the entire `height` of the plot. "paper" refers to the height of the plotting area only.</param>
117125
static member style
118126
(
119127
[<Optional; DefaultParameterValue(null)>] ?BGColor: Color,
@@ -137,8 +145,10 @@ type Legend() =
137145
[<Optional; DefaultParameterValue(null)>] ?Visible: bool,
138146
[<Optional; DefaultParameterValue(null)>] ?X: float,
139147
[<Optional; DefaultParameterValue(null)>] ?XAnchor: StyleParam.XAnchorPosition,
148+
[<Optional; DefaultParameterValue(null)>] ?XRef: string,
140149
[<Optional; DefaultParameterValue(null)>] ?Y: float,
141-
[<Optional; DefaultParameterValue(null)>] ?YAnchor: StyleParam.YAnchorPosition
150+
[<Optional; DefaultParameterValue(null)>] ?YAnchor: StyleParam.YAnchorPosition,
151+
[<Optional; DefaultParameterValue(null)>] ?YRef: string
142152
) =
143153
(fun (legend: Legend) ->
144154
BGColor |> DynObj.setValueOpt legend "bgcolor"
@@ -162,8 +172,10 @@ type Legend() =
162172
Visible |> DynObj.setValueOpt legend "visible"
163173
X |> DynObj.setValueOpt legend "x"
164174
XAnchor |> DynObj.setValueOptBy legend "xanchor" StyleParam.XAnchorPosition.convert
175+
XRef |> DynObj.setValueOpt legend "xref"
165176
Y |> DynObj.setValueOpt legend "y"
166177
YAnchor |> DynObj.setValueOptBy legend "yanchor" StyleParam.YAnchorPosition.convert
178+
YRef |> DynObj.setValueOpt legend "yref"
167179

168180

169181

src/Plotly.NET/Plotly.NET.fsproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
<ItemGroup>
4141
<None Include="RELEASE_NOTES.md" />
4242
<None Include="..\..\docs\img\logo.png" Pack="true" PackagePath="\" />
43-
<EmbeddedResource Include="plotly-2.22.0.min.js" />
44-
<EmbeddedResource Include="plotly-2.22.0.min.js.LICENSE.txt" />
43+
<EmbeddedResource Include="plotly-2.23.2.min.js" />
44+
<EmbeddedResource Include="plotly-2.23.2.min.js.LICENSE.txt" />
4545
<Compile Include="Globals.fs" />
4646
<Compile Include="InternalUtils.fs" />
4747
<Compile Include="CommonAbstractions\ColorKeyword.fs" />

src/Plotly.NET/RELEASE_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
[Milestone link with all the fixed/closed issues](https://github.com/plotly/Plotly.NET/milestone/5)
44

55
- Keep up with plotlyjs 2.x incremental updates:
6+
- v2.22:
7+
- [Implement multi legend support](https://github.com/plotly/Plotly.NET/issues/406)
68

79
### 4.2.0 - August 02 2023
810

src/Plotly.NET/plotly-2.22.0.min.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

src/Plotly.NET/plotly-2.23.2.min.js

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)