Skip to content

Commit 7b8ff1a

Browse files
committed
plotlyjs v 2.15: Add angle, angleref and standoff to marker and add backoff to line
1 parent 5744e15 commit 7b8ff1a

File tree

5 files changed

+64
-5
lines changed

5 files changed

+64
-5
lines changed

src/Plotly.NET/ChartAPI/GenericChart.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module HTML =
1515
<head>
1616
<!-- Plotly.js -->
1717
<meta http-equiv="X-UA-Compatible" content="IE=11" >
18-
<script src="https://cdn.plot.ly/plotly-2.14.0.min.js"></script>
18+
<script src="https://cdn.plot.ly/plotly-2.15.1.min.js"></script>
1919
[ADDITIONAL_HEAD_TAGS]
2020
<style>
2121
.container {
@@ -58,7 +58,7 @@ module HTML =
5858
newScript.AppendLine(
5959
@"
6060
var renderPlotly_[SCRIPTID] = function() {
61-
var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.14.0.min'}}) || require;
61+
var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.15.1.min'}}) || require;
6262
fsharpPlotlyRequire(['plotly'], function(Plotly) {"
6363
)
6464
|> ignore

src/Plotly.NET/CommonAbstractions/Line.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type Line() =
1111
/// <summary>
1212
/// Returns a new Line object with the given styling.
1313
/// </summary>
14+
/// <param name="BackOff">Sets the line back off from the end point of the nth line segment (in px). This option is useful e.g. to avoid overlap with arrowhead markers. With "auto" the lines would trim before markers if `marker.angleref` is set to "previous".</param>
1415
/// <param name="AutoColorScale">Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `line.colorscale`. Has an effect only if in `line.color`is set to a numerical array. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.</param>
1516
/// <param name="CAuto">Determines whether or not the color domain is computed with respect to the input data (here in `line.color`) or the bounds set in `line.cmin` and `line.cmax` Has an effect only if in `line.color`is set to a numerical array. Defaults to `false` when `line.cmin` and `line.cmax` are set by the user.</param>
1617
/// <param name="CMax">Sets the upper bound of the color domain. Has an effect only if in `line.color`is set to a numerical array. Value should have the same units as in `line.color` and if set, `line.cmin` must be set as well.</param>
@@ -32,6 +33,7 @@ type Line() =
3233
/// <param name="OutlierWidth">Sets the width of the outline of outliers</param>
3334
static member init
3435
(
36+
[<Optional; DefaultParameterValue(null)>] ?BackOff: StyleParam.BackOff,
3537
[<Optional; DefaultParameterValue(null)>] ?AutoColorScale: bool,
3638
[<Optional; DefaultParameterValue(null)>] ?CAuto: bool,
3739
[<Optional; DefaultParameterValue(null)>] ?CMax: float,
@@ -54,6 +56,7 @@ type Line() =
5456
) =
5557
Line()
5658
|> Line.style (
59+
?BackOff = BackOff,
5760
?AutoColorScale = AutoColorScale,
5861
?CAuto = CAuto,
5962
?CMax = CMax,
@@ -78,6 +81,7 @@ type Line() =
7881
/// <summary>
7982
/// Returns a function that applies the given styles to a Line object.
8083
/// </summary>
84+
/// <param name="BackOff">Sets the line back off from the end point of the nth line segment (in px). This option is useful e.g. to avoid overlap with arrowhead markers. With "auto" the lines would trim before markers if `marker.angleref` is set to "previous".</param>
8185
/// <param name="AutoColorScale">Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `line.colorscale`. Has an effect only if in `line.color`is set to a numerical array. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.</param>
8286
/// <param name="CAuto">Determines whether or not the color domain is computed with respect to the input data (here in `line.color`) or the bounds set in `line.cmin` and `line.cmax` Has an effect only if in `line.color`is set to a numerical array. Defaults to `false` when `line.cmin` and `line.cmax` are set by the user.</param>
8387
/// <param name="CMax">Sets the upper bound of the color domain. Has an effect only if in `line.color`is set to a numerical array. Value should have the same units as in `line.color` and if set, `line.cmin` must be set as well.</param>
@@ -99,6 +103,7 @@ type Line() =
99103
/// <param name="OutlierWidth">Sets the width of the outline of outliers</param>
100104
static member style
101105
(
106+
[<Optional; DefaultParameterValue(null)>] ?BackOff: StyleParam.BackOff,
102107
[<Optional; DefaultParameterValue(null)>] ?AutoColorScale: bool,
103108
[<Optional; DefaultParameterValue(null)>] ?CAuto: bool,
104109
[<Optional; DefaultParameterValue(null)>] ?CMax: float,
@@ -120,6 +125,7 @@ type Line() =
120125
[<Optional; DefaultParameterValue(null)>] ?OutlierWidth: float
121126
) =
122127
(fun (line: Line) ->
128+
BackOff |> DynObj.setValueOptBy line "backoff" StyleParam.BackOff.convert
123129
Color |> DynObj.setValueOpt line "color"
124130
(Width, MultiWidth) |> DynObj.setSingleOrMultiOpt line "width"
125131
Shape |> DynObj.setValueOptBy line "shape" StyleParam.Shape.convert

src/Plotly.NET/CommonAbstractions/StyleParams.fs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ module StyleParam =
1313
// #A#
1414
//--------------------------
1515

16+
[<RequireQualifiedAccess>]
17+
type AngleRef =
18+
| Previous
19+
| Up
20+
21+
static member toString =
22+
function
23+
| Previous -> "previous"
24+
| Up -> "up"
25+
26+
static member convert = AngleRef.toString >> box
27+
override this.ToString() = this |> AngleRef.toString
28+
member this.Convert() = this |> AngleRef.convert
29+
1630
[<RequireQualifiedAccess>]
1731
type ArrowSide =
1832
| Start
@@ -292,6 +306,22 @@ module StyleParam =
292306
// #B#
293307
//--------------------------
294308

309+
[<RequireQualifiedAccess>]
310+
type BackOff =
311+
| Auto
312+
| Value of int
313+
| Array of seq<int>
314+
315+
static member convert =
316+
function
317+
| Auto -> box "auto"
318+
| Value v -> box v
319+
| Array a -> box a
320+
321+
322+
member this.Convert() = this |> BackOff.convert
323+
324+
295325
[<RequireQualifiedAccess>]
296326
type BoxPoints =
297327
| Outliers

src/Plotly.NET/Traces/ObjectAbstractions/Marker.fs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ type Marker() =
1313
/// <summary>
1414
/// Returns a new Marker object with the given styling.
1515
/// </summary>
16+
/// <param name="Angle">Sets the marker angle in respect to `angleref`.</param>
17+
/// <param name="AngleRef">Sets the reference for marker angle. With "previous", angle 0 points along the line from the previous point to this one. With "up", angle 0 points toward the top of the screen.</param>
1618
/// <param name="AutoColorScale">Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. Has an effect only if in `marker.color`is set to a numerical array. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.</param>
1719
/// <param name="CAuto">Determines whether or not the color domain is computed with respect to the input data (here in `marker.color`) or the bounds set in `marker.cmin` and `marker.cmax` Has an effect only if in `marker.color`is set to a numerical array. Defaults to `false` when `marker.cmin` and `marker.cmax` are set by the user.</param>
1820
/// <param name="CMax">Sets the upper bound of the color domain. Has an effect only if in `marker.color`is set to a numerical array. Value should have the same units as in `marker.color` and if set, `marker.cmin` must be set as well.</param>
@@ -36,6 +38,8 @@ type Marker() =
3638
/// <param name="SizeMin">Has an effect only if `marker.size` is set to a numerical array. Sets the minimum size (in px) of the rendered marker points.</param>
3739
/// <param name="SizeMode">Has an effect only if `marker.size` is set to a numerical array. Sets the rule for which the data in `size` is converted to pixels.</param>
3840
/// <param name="SizeRef">Has an effect only if `marker.size` is set to a numerical array. Sets the scale factor used to determine the rendered size of marker points. Use with `sizemin` and `sizemode`.</param>
41+
/// <param name="StandOff">Moves the marker away from the data point in the direction of `angle` (in px). This can be useful for example if you have another marker at this location and you want to point an arrowhead marker at it.</param>
42+
/// <param name="MultiStandOff">Moves the marker away from the data point in the direction of `angle` (in px). This can be useful for example if you have another marker at this location and you want to point an arrowhead marker at it.</param>
3943
/// <param name="Symbol">Sets the marker symbol.</param>
4044
/// <param name="MultiSymbol">Sets the individual marker symbols.</param>
4145
/// <param name="Symbol3D">Sets the marker symbol for 3d traces.</param>
@@ -44,6 +48,8 @@ type Marker() =
4448
/// <param name="OutlierWidth">Sets the width of the outlier sample points.</param>
4549
static member init
4650
(
51+
[<Optional; DefaultParameterValue(null)>] ?Angle: float,
52+
[<Optional; DefaultParameterValue(null)>] ?AngleRef: StyleParam.AngleRef,
4753
[<Optional; DefaultParameterValue(null)>] ?AutoColorScale: bool,
4854
[<Optional; DefaultParameterValue(null)>] ?CAuto: bool,
4955
[<Optional; DefaultParameterValue(null)>] ?CMax: float,
@@ -67,6 +73,8 @@ type Marker() =
6773
[<Optional; DefaultParameterValue(null)>] ?SizeMin: int,
6874
[<Optional; DefaultParameterValue(null)>] ?SizeMode: StyleParam.MarkerSizeMode,
6975
[<Optional; DefaultParameterValue(null)>] ?SizeRef: int,
76+
[<Optional; DefaultParameterValue(null)>] ?StandOff: float,
77+
[<Optional; DefaultParameterValue(null)>] ?MultiStandOff: seq<float>,
7078
[<Optional; DefaultParameterValue(null)>] ?Symbol: StyleParam.MarkerSymbol,
7179
[<Optional; DefaultParameterValue(null)>] ?MultiSymbol: seq<StyleParam.MarkerSymbol>,
7280
[<Optional; DefaultParameterValue(null)>] ?Symbol3D: StyleParam.MarkerSymbol3D,
@@ -76,6 +84,8 @@ type Marker() =
7684
) =
7785
Marker()
7886
|> Marker.style (
87+
?Angle=Angle,
88+
?AngleRef=AngleRef,
7989
?AutoColorScale = AutoColorScale,
8090
?CAuto = CAuto,
8191
?CMax = CMax,
@@ -104,12 +114,16 @@ type Marker() =
104114
?ShowScale = ShowScale,
105115
?SizeMin = SizeMin,
106116
?SizeMode = SizeMode,
107-
?SizeRef = SizeRef
117+
?SizeRef = SizeRef,
118+
?StandOff = StandOff,
119+
?MultiStandOff = MultiStandOff
108120
)
109121

110122
/// <summary>
111123
/// Returns a function that applies the given styles to a Marker object.
112124
/// </summary>
125+
/// <param name="Angle">Sets the marker angle in respect to `angleref`.</param>
126+
/// <param name="AngleRef">Sets the reference for marker angle. With "previous", angle 0 points along the line from the previous point to this one. With "up", angle 0 points toward the top of the screen.</param>
113127
/// <param name="AutoColorScale">Determines whether the colorscale is a default palette (`autocolorscale: true`) or the palette determined by `marker.colorscale`. Has an effect only if in `marker.color`is set to a numerical array. In case `colorscale` is unspecified or `autocolorscale` is true, the default palette will be chosen according to whether numbers in the `color` array are all positive, all negative or mixed.</param>
114128
/// <param name="CAuto">Determines whether or not the color domain is computed with respect to the input data (here in `marker.color`) or the bounds set in `marker.cmin` and `marker.cmax` Has an effect only if in `marker.color`is set to a numerical array. Defaults to `false` when `marker.cmin` and `marker.cmax` are set by the user.</param>
115129
/// <param name="CMax">Sets the upper bound of the color domain. Has an effect only if in `marker.color`is set to a numerical array. Value should have the same units as in `marker.color` and if set, `marker.cmin` must be set as well.</param>
@@ -133,6 +147,8 @@ type Marker() =
133147
/// <param name="SizeMin">Has an effect only if `marker.size` is set to a numerical array. Sets the minimum size (in px) of the rendered marker points.</param>
134148
/// <param name="SizeMode">Has an effect only if `marker.size` is set to a numerical array. Sets the rule for which the data in `size` is converted to pixels.</param>
135149
/// <param name="SizeRef">Has an effect only if `marker.size` is set to a numerical array. Sets the scale factor used to determine the rendered size of marker points. Use with `sizemin` and `sizemode`.</param>
150+
/// <param name="StandOff">Moves the marker away from the data point in the direction of `angle` (in px). This can be useful for example if you have another marker at this location and you want to point an arrowhead marker at it.</param>
151+
/// <param name="MultiStandOff">Moves the marker away from the data point in the direction of `angle` (in px). This can be useful for example if you have another marker at this location and you want to point an arrowhead marker at it.</param>
136152
/// <param name="Symbol">Sets the marker symbol.</param>
137153
/// <param name="MultiSymbol">Sets the individual marker symbols.</param>
138154
/// <param name="Symbol3D">Sets the marker symbol for 3d traces.</param>
@@ -141,6 +157,8 @@ type Marker() =
141157
/// <param name="OutlierWidth">Sets the width of the outlier sample points.</param>
142158
static member style
143159
(
160+
[<Optional; DefaultParameterValue(null)>] ?Angle: float,
161+
[<Optional; DefaultParameterValue(null)>] ?AngleRef: StyleParam.AngleRef,
144162
[<Optional; DefaultParameterValue(null)>] ?AutoColorScale: bool,
145163
[<Optional; DefaultParameterValue(null)>] ?CAuto: bool,
146164
[<Optional; DefaultParameterValue(null)>] ?CMax: float,
@@ -164,6 +182,8 @@ type Marker() =
164182
[<Optional; DefaultParameterValue(null)>] ?SizeMin: int,
165183
[<Optional; DefaultParameterValue(null)>] ?SizeMode: StyleParam.MarkerSizeMode,
166184
[<Optional; DefaultParameterValue(null)>] ?SizeRef: int,
185+
[<Optional; DefaultParameterValue(null)>] ?StandOff: float,
186+
[<Optional; DefaultParameterValue(null)>] ?MultiStandOff: seq<float>,
167187
[<Optional; DefaultParameterValue(null)>] ?Symbol: StyleParam.MarkerSymbol,
168188
[<Optional; DefaultParameterValue(null)>] ?MultiSymbol: seq<StyleParam.MarkerSymbol>,
169189
[<Optional; DefaultParameterValue(null)>] ?Symbol3D: StyleParam.MarkerSymbol3D,
@@ -173,6 +193,8 @@ type Marker() =
173193
) =
174194
(fun (marker: Marker) ->
175195

196+
Angle |> DynObj.setValueOpt marker "angle"
197+
AngleRef |> DynObj.setValueOptBy marker "angleref" StyleParam.AngleRef.convert
176198
AutoColorScale |> DynObj.setValueOpt marker "autocolorscale"
177199
CAuto |> DynObj.setValueOpt marker "cauto"
178200
CMax |> DynObj.setValueOpt marker "cmax"
@@ -198,5 +220,6 @@ type Marker() =
198220
SizeMin |> DynObj.setValueOpt marker "sizemin"
199221
SizeMode |> DynObj.setValueOpt marker "sizemode"
200222
SizeRef |> DynObj.setValueOpt marker "sizeref"
223+
(StandOff, MultiStandOff) |> DynObj.setSingleOrMultiOpt marker "standoff"
201224

202225
marker)

tests/Plotly.NET.Tests/HtmlCodegen/SimpleTests.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ let simpleChart =
2020
let ``Html layout tests`` =
2121
testList "SimpleTests.Simple tests" [
2222
testCase "Expecting plotly js" ( fun () ->
23-
"https://cdn.plot.ly/plotly-2.14.0.min"
23+
"https://cdn.plot.ly/plotly-2.15.1.min"
2424
|> chartGeneratedContains simpleChart
2525
);
2626
testCase "Expecting data" ( fun () ->
@@ -36,7 +36,7 @@ let ``Html layout tests`` =
3636
|> chartGeneratedContains simpleChart
3737
);
3838
testCase "Expecting require config" (fun () ->
39-
"var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.14.0.min'}}) || require;"
39+
"var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.15.1.min'}}) || require;"
4040
|> chartGeneratedContains simpleChart
4141
);
4242
testCase "Expecting html tags in embedded page only" (fun () ->

0 commit comments

Comments
 (0)