Skip to content

Commit 92f92a5

Browse files
committed
plotlyjs v2.26: add new autorange options
- Add new options to the AutoRange StyleParam - Add `maxallowed` and `minallowed` to cartesian and radial axes - add new `AutoRangeOptions` object and respective settings to cartesian and radial axes - fix dependencies of tests projects: Expecto v10, F# update to 7 made tests undiscoverable
1 parent b64e942 commit 92f92a5

File tree

12 files changed

+481
-33
lines changed

12 files changed

+481
-33
lines changed
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
namespace Plotly.NET
2+
3+
open Plotly.NET
4+
open DynamicObj
5+
open System
6+
open System.Runtime.InteropServices
7+
8+
type AutoRangeOptions() =
9+
inherit DynamicObj()
10+
11+
/// <summary>
12+
/// Returns a new AutoRangeOptions object with the given styling.
13+
/// </summary>
14+
/// <param name="ClipMax">Clip autorange maximum if it goes beyond this value. Has no effect when `autorangeoptions.maxallowed` is provided.</param>
15+
/// <param name="ClipMin">Clip autorange minimum if it goes beyond this value. Has no effect when `autorangeoptions.minallowed` is provided.</param>
16+
/// <param name="Include">Ensure this value is included in autorange.</param>
17+
/// <param name="MaxAllowed">Use this value exactly as autorange maximum.</param>
18+
/// <param name="MinAllowed">Use this value exactly as autorange minimum.</param>
19+
static member init
20+
(
21+
[<Optional; DefaultParameterValue(null)>] ?ClipMax: #IConvertible,
22+
[<Optional; DefaultParameterValue(null)>] ?ClipMin: #IConvertible,
23+
[<Optional; DefaultParameterValue(null)>] ?Include: #IConvertible,
24+
[<Optional; DefaultParameterValue(null)>] ?MaxAllowed: #IConvertible,
25+
[<Optional; DefaultParameterValue(null)>] ?MinAllowed: #IConvertible
26+
) =
27+
AutoRangeOptions()
28+
|> AutoRangeOptions.style (
29+
?ClipMax = ClipMax,
30+
?ClipMin = ClipMin,
31+
?Include = Include,
32+
?MaxAllowed = MaxAllowed,
33+
?MinAllowed = MinAllowed
34+
)
35+
36+
/// <summary>
37+
/// Returns a function that applies the given styles to a AutoRangeOptions object.
38+
/// </summary>
39+
/// <param name="ClipMax">Clip autorange maximum if it goes beyond this value. Has no effect when `autorangeoptions.maxallowed` is provided.</param>
40+
/// <param name="ClipMin">Clip autorange minimum if it goes beyond this value. Has no effect when `autorangeoptions.minallowed` is provided.</param>
41+
/// <param name="Include">Ensure this value is included in autorange.</param>
42+
/// <param name="MaxAllowed">Use this value exactly as autorange maximum.</param>
43+
/// <param name="MinAllowed">Use this value exactly as autorange minimum.</param>
44+
static member style
45+
(
46+
[<Optional; DefaultParameterValue(null)>] ?ClipMax: #IConvertible,
47+
[<Optional; DefaultParameterValue(null)>] ?ClipMin: #IConvertible,
48+
[<Optional; DefaultParameterValue(null)>] ?Include: #IConvertible,
49+
[<Optional; DefaultParameterValue(null)>] ?MaxAllowed: #IConvertible,
50+
[<Optional; DefaultParameterValue(null)>] ?MinAllowed: #IConvertible
51+
52+
) =
53+
(fun (autoRangeOptions: AutoRangeOptions) ->
54+
55+
ClipMax |> DynObj.setValueOpt autoRangeOptions "clipmax"
56+
ClipMin |> DynObj.setValueOpt autoRangeOptions "clipmin"
57+
Include |> DynObj.setValueOpt autoRangeOptions "include"
58+
MaxAllowed |> DynObj.setValueOpt autoRangeOptions "maxallowed"
59+
MinAllowed |> DynObj.setValueOpt autoRangeOptions "minallowed"
60+
61+
autoRangeOptions)

src/Plotly.NET/CommonAbstractions/StyleParams.fs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,18 +124,28 @@ module StyleParam =
124124
override this.ToString() = this |> Align.toString
125125
member this.Convert() = this |> Align.convert
126126

127-
/// Determines whether or not the range of this axis is computed in relation to the input data. See `rangemode` for more info. If `range` is provided, then `autorange` is set to "false".
127+
/// <summary>
128+
/// Determines whether or not the range of this axis is computed in relation to the input data. See `rangemode` for more info. If `range` is provided and it has a value for both the lower and upper bound, `autorange` is set to "false". Using "min" applies autorange only to set the minimum. Using "max" applies autorange only to set the maximum. Using "min reversed" applies autorange only to set the minimum on a reversed axis. Using "max reversed" applies autorange only to set the maximum on a reversed axis. Using "reversed" applies autorange on both ends and reverses the axis direction.
129+
/// </summary>
128130
[<RequireQualifiedAccess>]
129131
type AutoRange =
130132
| True
131133
| False
132134
| Reversed
135+
| MinReversed
136+
| MaxReversed
137+
| Min
138+
| Max
133139

134140
static member convert =
135141
function
136142
| True -> box true
137143
| False -> box false
138144
| Reversed -> box "reversed"
145+
| MinReversed -> box "min reversed"
146+
| MaxReversed -> box "max reversed"
147+
| Min -> box "min"
148+
| Max -> box "max"
139149

140150
member this.Convert() = this |> AutoRange.convert
141151

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ type LinearAxis() =
1818
/// <param name="AxisType">Sets the axis type. By default, plotly attempts to determined the axis type by looking into the data of the traces that referenced the axis in question.</param>
1919
/// <param name="AutoTypeNumbers">Using "strict" a numeric string in trace data is not converted to a number. Using "convert types" a numeric string in trace data may be treated as a number during automatic axis `type` detection. Defaults to layout.autotypenumbers.</param>
2020
/// <param name="AutoRange">Determines whether or not the range of this axis is computed in relation to the input data. See `rangemode` for more info. If `range` is provided, then `autorange` is set to "false".</param>
21+
/// <param name="AutoRangeOptions">Additional options for bounding the autorange</param>
2122
/// <param name="AutoShift">Automatically reposition the axis to avoid overlap with other axes with the same `overlaying` value. This repositioning will account for any `shift` amount applied to other axes on the same side with `autoshift` is set to true. Only has an effect if `anchor` is set to "free".</param>
2223
/// <param name="RangeMode">If "normal", the range is computed in relation to the extrema of the input data. If "tozero"`, the range extends to 0, regardless of the input data If "nonnegative", the range is non-negative, regardless of the input data. Applies only to linear axes.</param>
2324
/// <param name="Range">Sets the range of this axis. If the axis `type` is "log", then you must take the log of your desired range (e.g. to set the range from 1 to 100, set the range from 0 to 2). If the axis `type` is "date", it should be date strings, like date data, though Date objects and unix milliseconds will be accepted and converted to strings. If the axis `type` is "category", it should be numbers, using the scale where each category is assigned a serial number from zero in the order it appears.</param>
@@ -27,6 +28,8 @@ type LinearAxis() =
2728
/// <param name="Constrain">If this axis needs to be compressed (either due to its own `scaleanchor` and `scaleratio` or those of the other axis), determines how that happens: by increasing the "range", or by decreasing the "domain". Default is "domain" for axes containing image traces, "range" otherwise.</param>
2829
/// <param name="ConstrainToward">If this axis needs to be compressed (either due to its own `scaleanchor` and `scaleratio` or those of the other axis), determines which direction we push the originally specified plot area. Options are "left", "center" (default), and "right" for x axes, and "top", "middle" (default), and "bottom" for y axes.</param>
2930
/// <param name="Matches">If set to another axis id (e.g. `x2`, `y`), the range of this axis will match the range of the corresponding axis in data-coordinates space. Moreover, matching axes share auto-range values, category lists and histogram auto-bins. Note that setting axes simultaneously in both a `scaleanchor` and a `matches` constraint is currently forbidden. Moreover, note that matching axes must have the same `type`.</param>
31+
/// <param name="MaxAllowed">Determines the maximum range of this axis.</param>
32+
/// <param name="MinAllowed">Determines the minimum range of this axis.</param>
3033
/// <param name="Rangebreaks">Sets breaks in the axis range</param>
3134
/// <param name="TickMode">Sets the tick mode for this axis. If "auto", the number of ticks is set via `nticks`. If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` ("linear" is the default value if `tick0` and `dtick` are provided). If "array", the placement of the ticks is set via `tickvals` and the tick text is `ticktext`. ("array" is the default value if `tickvals` is provided). If "sync", the number of ticks will sync with the overlayed axis set by `overlaying` property.</param>
3235
/// <param name="NTicks">Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to "auto".</param>
@@ -103,6 +106,7 @@ type LinearAxis() =
103106
[<Optional; DefaultParameterValue(null)>] ?AxisType: StyleParam.AxisType,
104107
[<Optional; DefaultParameterValue(null)>] ?AutoTypeNumbers: StyleParam.AutoTypeNumbers,
105108
[<Optional; DefaultParameterValue(null)>] ?AutoRange: StyleParam.AutoRange,
109+
[<Optional; DefaultParameterValue(null)>] ?AutoRangeOptions: AutoRangeOptions,
106110
[<Optional; DefaultParameterValue(null)>] ?AutoShift: bool,
107111
[<Optional; DefaultParameterValue(null)>] ?RangeMode: StyleParam.RangeMode,
108112
[<Optional; DefaultParameterValue(null)>] ?Range: StyleParam.Range,
@@ -112,6 +116,8 @@ type LinearAxis() =
112116
[<Optional; DefaultParameterValue(null)>] ?Constrain: StyleParam.AxisConstraint,
113117
[<Optional; DefaultParameterValue(null)>] ?ConstrainToward: StyleParam.AxisConstraintDirection,
114118
[<Optional; DefaultParameterValue(null)>] ?Matches: StyleParam.LinearAxisId,
119+
[<Optional; DefaultParameterValue(null)>] ?MaxAllowed: #IConvertible,
120+
[<Optional; DefaultParameterValue(null)>] ?MinAllowed: #IConvertible,
115121
[<Optional; DefaultParameterValue(null)>] ?Rangebreaks: seq<Rangebreak>,
116122
[<Optional; DefaultParameterValue(null)>] ?TickMode: StyleParam.TickMode,
117123
[<Optional; DefaultParameterValue(null)>] ?NTicks: int,
@@ -189,6 +195,7 @@ type LinearAxis() =
189195
?AxisType = AxisType,
190196
?AutoTypeNumbers = AutoTypeNumbers,
191197
?AutoRange = AutoRange,
198+
?AutoRangeOptions = AutoRangeOptions,
192199
?AutoShift = AutoShift,
193200
?RangeMode = RangeMode,
194201
?Range = Range,
@@ -198,6 +205,8 @@ type LinearAxis() =
198205
?Constrain = Constrain,
199206
?ConstrainToward = ConstrainToward,
200207
?Matches = Matches,
208+
?MinAllowed = MinAllowed,
209+
?MaxAllowed = MaxAllowed,
201210
?Rangebreaks = Rangebreaks,
202211
?TickMode = TickMode,
203212
?NTicks = NTicks,
@@ -789,6 +798,7 @@ type LinearAxis() =
789798
/// <param name="AutoTypeNumbers">Using "strict" a numeric string in trace data is not converted to a number. Using "convert types" a numeric string in trace data may be treated as a number during automatic axis `type` detection. Defaults to layout.autotypenumbers.</param>
790799
/// <param name="AutoShift">Automatically reposition the axis to avoid overlap with other axes with the same `overlaying` value. This repositioning will account for any `shift` amount applied to other axes on the same side with `autoshift` is set to true. Only has an effect if `anchor` is set to "free".</param>
791800
/// <param name="AutoRange">Determines whether or not the range of this axis is computed in relation to the input data. See `rangemode` for more info. If `range` is provided, then `autorange` is set to "false".</param>
801+
/// <param name="AutoRangeOptions">Additional options for bounding the autorange</param>
792802
/// <param name="RangeMode">If "normal", the range is computed in relation to the extrema of the input data. If "tozero"`, the range extends to 0, regardless of the input data If "nonnegative", the range is non-negative, regardless of the input data. Applies only to linear axes.</param>
793803
/// <param name="Range">Sets the range of this axis. If the axis `type` is "log", then you must take the log of your desired range (e.g. to set the range from 1 to 100, set the range from 0 to 2). If the axis `type` is "date", it should be date strings, like date data, though Date objects and unix milliseconds will be accepted and converted to strings. If the axis `type` is "category", it should be numbers, using the scale where each category is assigned a serial number from zero in the order it appears.</param>
794804
/// <param name="FixedRange">Determines whether or not this axis is zoom-able. If true, then zoom is disabled.</param>
@@ -797,6 +807,8 @@ type LinearAxis() =
797807
/// <param name="Constrain">If this axis needs to be compressed (either due to its own `scaleanchor` and `scaleratio` or those of the other axis), determines how that happens: by increasing the "range", or by decreasing the "domain". Default is "domain" for axes containing image traces, "range" otherwise.</param>
798808
/// <param name="ConstrainToward">If this axis needs to be compressed (either due to its own `scaleanchor` and `scaleratio` or those of the other axis), determines which direction we push the originally specified plot area. Options are "left", "center" (default), and "right" for x axes, and "top", "middle" (default), and "bottom" for y axes.</param>
799809
/// <param name="Matches">If set to another axis id (e.g. `x2`, `y`), the range of this axis will match the range of the corresponding axis in data-coordinates space. Moreover, matching axes share auto-range values, category lists and histogram auto-bins. Note that setting axes simultaneously in both a `scaleanchor` and a `matches` constraint is currently forbidden. Moreover, note that matching axes must have the same `type`.</param>
810+
/// <param name="MaxAllowed">Determines the maximum range of this axis.</param>
811+
/// <param name="MinAllowed">Determines the minimum range of this axis.</param>
800812
/// <param name="Rangebreaks">Sets breaks in the axis range</param>
801813
/// <param name="TickMode">Sets the tick mode for this axis. If "auto", the number of ticks is set via `nticks`. If "linear", the placement of the ticks is determined by a starting position `tick0` and a tick step `dtick` ("linear" is the default value if `tick0` and `dtick` are provided). If "array", the placement of the ticks is set via `TickVals` and the tick text is `TickText`. ("array" is the default value if `TickVals` is provided).</param>
802814
/// <param name="NTicks">Specifies the maximum number of ticks for the particular axis. The actual number of ticks will be chosen automatically to be less than or equal to `nticks`. Has an effect only if `tickmode` is set to "auto".</param>
@@ -890,6 +902,7 @@ type LinearAxis() =
890902
[<Optional; DefaultParameterValue(null)>] ?AxisType: StyleParam.AxisType,
891903
[<Optional; DefaultParameterValue(null)>] ?AutoTypeNumbers: StyleParam.AutoTypeNumbers,
892904
[<Optional; DefaultParameterValue(null)>] ?AutoRange: StyleParam.AutoRange,
905+
[<Optional; DefaultParameterValue(null)>] ?AutoRangeOptions: AutoRangeOptions,
893906
[<Optional; DefaultParameterValue(null)>] ?AutoShift: bool,
894907
[<Optional; DefaultParameterValue(null)>] ?RangeMode: StyleParam.RangeMode,
895908
[<Optional; DefaultParameterValue(null)>] ?Range: StyleParam.Range,
@@ -899,6 +912,8 @@ type LinearAxis() =
899912
[<Optional; DefaultParameterValue(null)>] ?Constrain: StyleParam.AxisConstraint,
900913
[<Optional; DefaultParameterValue(null)>] ?ConstrainToward: StyleParam.AxisConstraintDirection,
901914
[<Optional; DefaultParameterValue(null)>] ?Matches: StyleParam.LinearAxisId,
915+
[<Optional; DefaultParameterValue(null)>] ?MaxAllowed: #IConvertible,
916+
[<Optional; DefaultParameterValue(null)>] ?MinAllowed: #IConvertible,
902917
[<Optional; DefaultParameterValue(null)>] ?Rangebreaks: seq<Rangebreak>,
903918
[<Optional; DefaultParameterValue(null)>] ?TickMode: StyleParam.TickMode,
904919
[<Optional; DefaultParameterValue(null)>] ?NTicks: int,
@@ -993,6 +1008,7 @@ type LinearAxis() =
9931008
AxisType |> DynObj.setValueOptBy axis "type" StyleParam.AxisType.convert
9941009
AutoTypeNumbers |> DynObj.setValueOptBy axis "autotypenumbers" StyleParam.AutoTypeNumbers.convert
9951010
AutoRange |> DynObj.setValueOptBy axis "autorange" StyleParam.AutoRange.convert
1011+
AutoRangeOptions |> DynObj.setValueOpt axis "autorangeoptions"
9961012
AutoShift |> DynObj.setValueOpt axis "autoshift"
9971013
RangeMode |> DynObj.setValueOptBy axis "rangemode" StyleParam.RangeMode.convert
9981014
Range |> DynObj.setValueOptBy axis "range" StyleParam.Range.convert
@@ -1002,6 +1018,8 @@ type LinearAxis() =
10021018
Constrain |> DynObj.setValueOptBy axis "constrain" StyleParam.AxisConstraint.convert
10031019
ConstrainToward |> DynObj.setValueOptBy axis "constraintoward" StyleParam.AxisConstraintDirection.convert
10041020
Matches |> DynObj.setValueOptBy axis "matches" StyleParam.LinearAxisId.convert
1021+
MaxAllowed |> DynObj.setValueOpt axis "maxallowed"
1022+
MinAllowed |> DynObj.setValueOpt axis "minallowed"
10051023
Rangebreaks |> DynObj.setValueOpt axis "rangebreaks"
10061024
TickMode |> DynObj.setValueOptBy axis "tickmode" StyleParam.TickMode.convert
10071025
NTicks |> DynObj.setValueOpt axis "nticks"

0 commit comments

Comments
 (0)