Skip to content

Commit 58124c6

Browse files
committed
change getters/setters to static members of the tzrace type, rework Error related functions, add tests for that
1 parent 5452be4 commit 58124c6

File tree

11 files changed

+407
-115
lines changed

11 files changed

+407
-115
lines changed

src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ module GenericChartExtensions =
205205
/// Apply styling to the yError(s) of the chart as Object
206206
[<CompiledName("WithYError")>]
207207
[<Extension>]
208-
member this.WithYError(yError: Error) =
209-
this |> mapTrace (TraceStyle.SetErrorY(yError))
208+
member this.WithYError(yError: Error) = this |> Chart.withYError (yError)
210209

211210
/// Apply styling to the yError(s) of the chart as Object
212211
[<CompiledName("WithYErrorStyle")>]
@@ -235,8 +234,7 @@ module GenericChartExtensions =
235234
/// Apply styling to the zError(s) of the chart as Object
236235
[<CompiledName("WithZError")>]
237236
[<Extension>]
238-
member this.WithZError(zError: Error) =
239-
this |> mapTrace (TraceStyle.SetErrorZ(zError))
237+
member this.WithZError(zError: Error) = this |> Chart.withZError (zError)
240238

241239

242240
/// Apply styling to the zError(s) of the chart as Object

src/Plotly.NET/ChartAPI/Chart.fs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ type Chart =
146146
/// <param name="marker">The new marker for the chart's trace(s)</param>
147147
[<CompiledName("WithMarker")>]
148148
static member withMarker(marker: Marker) =
149-
(fun (ch: GenericChart) -> ch |> mapTrace (TraceStyle.SetMarker(marker)))
149+
(fun (ch: GenericChart) -> ch |> mapTrace (Trace.setMarker (marker)))
150150

151151
/// <summary>
152152
/// Applies the given styles to the marker object(s) of the chart's trace(s).
@@ -255,7 +255,7 @@ type Chart =
255255
/// <param name="line">The new line for the chart's trace(s)</param>
256256
[<CompiledName("WithLine")>]
257257
static member withLine(line: Line) =
258-
(fun (ch: GenericChart) -> ch |> mapTrace (TraceStyle.SetLine(line)))
258+
(fun (ch: GenericChart) -> ch |> mapTrace (Trace.setLine (line)))
259259

260260
/// Apply styling to the Line(s) of the chart.
261261
[<CompiledName("WithLineStyle")>]
@@ -310,7 +310,7 @@ type Chart =
310310
/// Apply styling to the xError(s) of the chart as Object
311311
[<CompiledName("WithXError")>]
312312
static member withXError(xError: Error) =
313-
(fun (ch: GenericChart) -> ch |> mapTrace (TraceStyle.SetErrorX(xError)))
313+
(fun (ch: GenericChart) -> ch |> mapTrace (Trace.SetXError(xError)))
314314

315315
/// Apply styling to the xError(s) of the chart as Object
316316
[<CompiledName("WithXErrorStyle")>]
@@ -338,7 +338,7 @@ type Chart =
338338
/// Apply styling to the yError(s) of the chart as Object
339339
[<CompiledName("WithYError")>]
340340
static member withYError(yError: Error) =
341-
(fun (ch: GenericChart) -> ch |> mapTrace (TraceStyle.SetErrorY(yError)))
341+
(fun (ch: GenericChart) -> ch |> mapTrace (Trace.SetYError(yError)))
342342

343343
/// Apply styling to the yError(s) of the chart as Object
344344
[<CompiledName("WithYErrorStyle")>]
@@ -366,7 +366,7 @@ type Chart =
366366
/// Apply styling to the zError(s) of the chart as Object
367367
[<CompiledName("WithZError")>]
368368
static member withZError(zError: Error) =
369-
(fun (ch: GenericChart) -> ch |> mapTrace (TraceStyle.SetErrorZ(zError)))
369+
(fun (ch: GenericChart) -> ch |> mapTrace (Trace.SetZError(zError)))
370370

371371
/// Apply styling to the zError(s) of the chart as Object
372372
[<CompiledName("WithZErrorStyle")>]

src/Plotly.NET/ChartAPI/Chart2D.fs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3066,8 +3066,8 @@ module Chart2D =
30663066
/// <param name="MarkerColor">Sets the color of the histogram's bars.</param>
30673067
/// <param name="Marker">Sets the marker for the histogram's bars (use this for more finegrained control than the other marker-associated arguments).</param>
30683068
/// <param name="Line">Sets the outline of the histogram's bars.</param>
3069-
/// <param name="ErrorX">Sets the x error of this trace.</param>
3070-
/// <param name="ErrorY">Sets the y error of this trace.</param>
3069+
/// <param name="XError">Sets the x error of this trace.</param>
3070+
/// <param name="YError">Sets the y error of this trace.</param>
30713071
/// <param name="Cumulative">Sets wether and how the cumulative distribution is displayed</param>
30723072
/// <param name="HoverLabel">Sets the style of the hoverlabels of this trace.</param>
30733073
/// <param name="UseDefaults">If set to false, ignore the global default settings set in `Defaults`</param>
@@ -3094,8 +3094,8 @@ module Chart2D =
30943094
[<Optional; DefaultParameterValue(null)>] ?MarkerColor: Color,
30953095
[<Optional; DefaultParameterValue(null)>] ?Marker: Marker,
30963096
[<Optional; DefaultParameterValue(null)>] ?Line: Line,
3097-
[<Optional; DefaultParameterValue(null)>] ?ErrorX: Error,
3098-
[<Optional; DefaultParameterValue(null)>] ?ErrorY: Error,
3097+
[<Optional; DefaultParameterValue(null)>] ?XError: Error,
3098+
[<Optional; DefaultParameterValue(null)>] ?YError: Error,
30993099
[<Optional; DefaultParameterValue(null)>] ?Cumulative: Cumulative,
31003100
[<Optional; DefaultParameterValue(null)>] ?HoverLabel: Hoverlabel,
31013101
[<Optional; DefaultParameterValue(true)>] ?UseDefaults: bool
@@ -3122,8 +3122,8 @@ module Chart2D =
31223122
?YBins = YBins,
31233123
?Marker = Marker,
31243124
?Line = Line,
3125-
?ErrorX = ErrorX,
3126-
?ErrorY = ErrorY,
3125+
?XError = XError,
3126+
?YError = YError,
31273127
?Cumulative = Cumulative,
31283128
?HoverLabel = HoverLabel
31293129
)
@@ -3187,8 +3187,8 @@ module Chart2D =
31873187
[<Optional; DefaultParameterValue(null)>] ?MarkerColor: Color,
31883188
[<Optional; DefaultParameterValue(null)>] ?Marker: Marker,
31893189
[<Optional; DefaultParameterValue(null)>] ?Line: Line,
3190-
[<Optional; DefaultParameterValue(null)>] ?ErrorX: Error,
3191-
[<Optional; DefaultParameterValue(null)>] ?ErrorY: Error,
3190+
[<Optional; DefaultParameterValue(null)>] ?XError: Error,
3191+
[<Optional; DefaultParameterValue(null)>] ?YError: Error,
31923192
[<Optional; DefaultParameterValue(null)>] ?Cumulative: Cumulative,
31933193
[<Optional; DefaultParameterValue(null)>] ?HoverLabel: Hoverlabel,
31943194
[<Optional; DefaultParameterValue(true)>] ?UseDefaults: bool
@@ -3214,8 +3214,8 @@ module Chart2D =
32143214
?YBins = YBins,
32153215
?Marker = Marker,
32163216
?Line = Line,
3217-
?ErrorX = ErrorX,
3218-
?ErrorY = ErrorY,
3217+
?XError = XError,
3218+
?YError = YError,
32193219
?Cumulative = Cumulative,
32203220
?HoverLabel = HoverLabel
32213221
)

src/Plotly.NET/Templates/ChartTemplates.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ module ChartTemplates =
355355
[
356356
Trace2D.initBar (
357357
Trace2DStyle.Bar(
358-
ErrorX = Error.init (Color = Color.fromHex "#2a3f5f"),
359-
ErrorY = Error.init (Color = Color.fromHex "#2a3f5f"),
358+
XError = Error.init (Color = Color.fromHex "#2a3f5f"),
359+
YError = Error.init (Color = Color.fromHex "#2a3f5f"),
360360
Marker =
361361
Marker.init (
362362
Outline = Line.init (Color = Color.fromHex "#E5ECF6", Width = 0.5),

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ open System.Runtime.InteropServices
1010
type Error() =
1111
inherit DynamicObj()
1212

13-
/// <summary>Init Error type</summary>
13+
/// <summary>
14+
/// Returns a new Error object with the given styling.
15+
/// </summary>
1416
/// <param name ="Visible">Determines whether or not this set of error bars is visible.</param>
1517
/// <param name ="Type">Determines the rule used to generate the error bars. If "constant`, the bar lengths are of a constant value. Set this constant in `value`. If "percent", the bar lengths correspond to a percentage of underlying data. Set this percentage in `value`. If "sqrt", the bar lengths correspond to the square of the underlying data. If "data", the bar lengths are set with data set `array`.</param>
1618
/// <param name ="Symmetric">Determines whether or not the error bars have the same length in both direction (top/bottom for vertical bars, left/right for horizontal bars.</param>
@@ -42,6 +44,8 @@ type Error() =
4244
) =
4345
Error()
4446
|> Error.style (
47+
?Visible = Visible,
48+
?Type = Type,
4549
?Symmetric = Symmetric,
4650
?Array = Array,
4751
?Arrayminus = Arrayminus,
@@ -55,7 +59,9 @@ type Error() =
5559
?Width = Width
5660
)
5761

58-
/// <summary>Creates a function that applies the given style parameters to an Error object</summary>
62+
/// <summary>
63+
/// Returns a function that applies the given style parameters to an Error object
64+
/// </summary>
5965
/// <param name ="Visible">Determines whether or not this set of error bars is visible.</param>
6066
/// <param name ="Type">Determines the rule used to generate the error bars. If "constant`, the bar lengths are of a constant value. Set this constant in `value`. If "percent", the bar lengths correspond to a percentage of underlying data. Set this percentage in `value`. If "sqrt", the bar lengths correspond to the square of the underlying data. If "data", the bar lengths are set with data set `array`.</param>
6167
/// <param name ="Symmetric">Determines whether or not the error bars have the same length in both direction (top/bottom for vertical bars, left/right for horizontal bars.</param>

0 commit comments

Comments
 (0)