Skip to content

Commit 6560df0

Browse files
committed
Properly document and extend all functions that set/style line objects
1 parent 9187d05 commit 6560df0

File tree

7 files changed

+286
-140
lines changed

7 files changed

+286
-140
lines changed

src/Plotly.NET/CSharpLayer/GenericChartExtensions.fs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,21 +130,47 @@ module GenericChartExtensions =
130130
[<Extension>]
131131
member this.WithLineStyle
132132
(
133-
[<Optional; DefaultParameterValue(null)>] ?Width,
134-
[<Optional; DefaultParameterValue(null)>] ?Color,
135-
[<Optional; DefaultParameterValue(null)>] ?Shape,
136-
[<Optional; DefaultParameterValue(null)>] ?Dash,
137-
[<Optional; DefaultParameterValue(null)>] ?Smoothing,
138-
[<Optional; DefaultParameterValue(null)>] ?Colorscale
133+
[<Optional; DefaultParameterValue(null)>] ?AutoColorScale: bool,
134+
[<Optional; DefaultParameterValue(null)>] ?CAuto: bool,
135+
[<Optional; DefaultParameterValue(null)>] ?CMax: float,
136+
[<Optional; DefaultParameterValue(null)>] ?CMid: float,
137+
[<Optional; DefaultParameterValue(null)>] ?CMin: float,
138+
[<Optional; DefaultParameterValue(null)>] ?Color: Color,
139+
[<Optional; DefaultParameterValue(null)>] ?ColorAxis: StyleParam.SubPlotId,
140+
[<Optional; DefaultParameterValue(null)>] ?Colorscale: StyleParam.Colorscale,
141+
[<Optional; DefaultParameterValue(null)>] ?ReverseScale: bool,
142+
[<Optional; DefaultParameterValue(null)>] ?ShowScale: bool,
143+
[<Optional; DefaultParameterValue(null)>] ?ColorBar: ColorBar,
144+
[<Optional; DefaultParameterValue(null)>] ?Dash: StyleParam.DrawingStyle,
145+
[<Optional; DefaultParameterValue(null)>] ?Shape: StyleParam.Shape,
146+
[<Optional; DefaultParameterValue(null)>] ?Simplify: bool,
147+
[<Optional; DefaultParameterValue(null)>] ?Smoothing: float,
148+
[<Optional; DefaultParameterValue(null)>] ?Width: float,
149+
[<Optional; DefaultParameterValue(null)>] ?MultiWidth: seq<float>,
150+
[<Optional; DefaultParameterValue(null)>] ?OutlierColor: Color,
151+
[<Optional; DefaultParameterValue(null)>] ?OutlierWidth: float
139152
) =
140153
this
141154
|> Chart.withLineStyle (
142-
?Width = Width,
155+
?AutoColorScale = AutoColorScale,
156+
?CAuto = CAuto,
157+
?CMax = CMax,
158+
?CMid = CMid,
159+
?CMin = CMin,
143160
?Color = Color,
144-
?Shape = Shape,
161+
?ColorAxis = ColorAxis,
162+
?Colorscale = Colorscale,
163+
?ReverseScale = ReverseScale,
164+
?ShowScale = ShowScale,
165+
?ColorBar = ColorBar,
145166
?Dash = Dash,
167+
?Shape = Shape,
168+
?Simplify = Simplify,
146169
?Smoothing = Smoothing,
147-
?Colorscale = Colorscale
170+
?Width = Width,
171+
?MultiWidth = MultiWidth,
172+
?OutlierColor = OutlierColor,
173+
?OutlierWidth = OutlierWidth
148174
)
149175

150176
/// Apply styling to the xError(s) of the chart as Object

src/Plotly.NET/ChartAPI/Chart.fs

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,10 @@ type Chart =
249249
)
250250
)
251251

252-
/// Apply styling to the Line(s) of the chart as Object.
252+
/// <summary>
253+
/// Sets the line for the chart's trace(s).
254+
/// </summary>
255+
/// <param name="line">The new line for the chart's trace(s)</param>
253256
[<CompiledName("WithLine")>]
254257
static member withLine(line: Line) =
255258
(fun (ch: GenericChart) -> ch |> mapTrace (TraceStyle.SetLine(line)))
@@ -258,29 +261,52 @@ type Chart =
258261
[<CompiledName("WithLineStyle")>]
259262
static member withLineStyle
260263
(
261-
[<Optional; DefaultParameterValue(null)>] ?Width,
262-
[<Optional; DefaultParameterValue(null)>] ?Color,
263-
[<Optional; DefaultParameterValue(null)>] ?Shape,
264-
[<Optional; DefaultParameterValue(null)>] ?Dash,
265-
[<Optional; DefaultParameterValue(null)>] ?Smoothing,
266-
[<Optional; DefaultParameterValue(null)>] ?Colorscale,
267-
[<Optional; DefaultParameterValue(null)>] ?OutlierColor,
268-
[<Optional; DefaultParameterValue(null)>] ?OutlierWidth
264+
[<Optional; DefaultParameterValue(null)>] ?AutoColorScale: bool,
265+
[<Optional; DefaultParameterValue(null)>] ?CAuto: bool,
266+
[<Optional; DefaultParameterValue(null)>] ?CMax: float,
267+
[<Optional; DefaultParameterValue(null)>] ?CMid: float,
268+
[<Optional; DefaultParameterValue(null)>] ?CMin: float,
269+
[<Optional; DefaultParameterValue(null)>] ?Color: Color,
270+
[<Optional; DefaultParameterValue(null)>] ?ColorAxis: StyleParam.SubPlotId,
271+
[<Optional; DefaultParameterValue(null)>] ?Colorscale: StyleParam.Colorscale,
272+
[<Optional; DefaultParameterValue(null)>] ?ReverseScale: bool,
273+
[<Optional; DefaultParameterValue(null)>] ?ShowScale: bool,
274+
[<Optional; DefaultParameterValue(null)>] ?ColorBar: ColorBar,
275+
[<Optional; DefaultParameterValue(null)>] ?Dash: StyleParam.DrawingStyle,
276+
[<Optional; DefaultParameterValue(null)>] ?Shape: StyleParam.Shape,
277+
[<Optional; DefaultParameterValue(null)>] ?Simplify: bool,
278+
[<Optional; DefaultParameterValue(null)>] ?Smoothing: float,
279+
[<Optional; DefaultParameterValue(null)>] ?Width: float,
280+
[<Optional; DefaultParameterValue(null)>] ?MultiWidth: seq<float>,
281+
[<Optional; DefaultParameterValue(null)>] ?OutlierColor: Color,
282+
[<Optional; DefaultParameterValue(null)>] ?OutlierWidth: float
269283
) =
270-
let line =
271-
Line.init (
272-
?Width = Width,
273-
?Color = Color,
274-
?Shape = Shape,
275-
?Dash = Dash,
276-
?Smoothing = Smoothing,
277-
?Colorscale = Colorscale,
278-
?OutlierColor = OutlierColor,
279-
?OutlierWidth = OutlierWidth
284+
fun (ch: GenericChart) ->
285+
ch
286+
|> mapTrace (
287+
TraceStyle.Line(
288+
?AutoColorScale = AutoColorScale,
289+
?CAuto = CAuto,
290+
?CMax = CMax,
291+
?CMid = CMid,
292+
?CMin = CMin,
293+
?Color = Color,
294+
?ColorAxis = ColorAxis,
295+
?Colorscale = Colorscale,
296+
?ReverseScale = ReverseScale,
297+
?ShowScale = ShowScale,
298+
?ColorBar = ColorBar,
299+
?Dash = Dash,
300+
?Shape = Shape,
301+
?Simplify = Simplify,
302+
?Smoothing = Smoothing,
303+
?Width = Width,
304+
?MultiWidth = MultiWidth,
305+
?OutlierColor = OutlierColor,
306+
?OutlierWidth = OutlierWidth
307+
)
280308
)
281309

282-
Chart.withLine (line)
283-
284310
/// Apply styling to the xError(s) of the chart as Object
285311
[<CompiledName("WithXError")>]
286312
static member withXError(xError: Error) =

src/Plotly.NET/Layout/ObjectAbstractions/Common/ColorBar.fs renamed to src/Plotly.NET/CommonAbstractions/ColorBar.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Plotly.NET.LayoutObjects
1+
namespace Plotly.NET
22

33
open Plotly.NET
44
open DynamicObj

src/Plotly.NET/CommonAbstractions/Line.fs

Lines changed: 76 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,77 +4,120 @@ open System.Runtime.InteropServices
44
open DynamicObj
55
open System
66

7-
/// Line type inherits from dynamic object
7+
/// The line object determines the style of the line in various aspect of plots such as a line connecting datums, outline of layout objects, etc..
88
type Line() =
99
inherit DynamicObj()
1010

11-
/// Initialized Line object
11+
/// <summary>
12+
/// Returns a new Line object with the given styling.
13+
/// </summary>
14+
/// <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>
15+
/// <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>
16+
/// <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>
17+
/// <param name="CMid">Sets the mid-point of the color domain by scaling `line.cmin` and/or `line.cmax` to be equidistant to this point. Has an effect only if in `line.color`is set to a numerical array. Value should have the same units as in `line.color`. Has no effect when `line.cauto` is `false`.</param>
18+
/// <param name="CMin">Sets the lower 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.cmax` must be set as well.</param>
19+
/// <param name="Color">Sets the line color.</param>
20+
/// <param name="ColorAxis">Sets a reference to a shared color axis. References to these shared color axes are "coloraxis", "coloraxis2", "coloraxis3", etc. Settings for these shared color axes are set in the layout, under `layout.coloraxis`, `layout.coloraxis2`, etc. Note that multiple color scales can be linked to the same color axis.</param>
21+
/// <param name="Colorscale">Sets the line colorscale</param>
22+
/// <param name="ReverseScale">Reverses the color mapping if true.</param>
23+
/// <param name="ShowScale">Wether or not to show the color bar</param>
24+
/// <param name="ColorBar">Sets the colorbar.</param>
25+
/// <param name="Dash">Sets the dash style of lines. Set to a dash type string ("solid", "dot", "dash", "longdash", "dashdot", or "longdashdot") or a dash length list in px (eg "5px,10px,2px,2px").</param>
26+
/// <param name="Shape">Determines the line shape. With "spline" the lines are drawn using spline interpolation. The other available values correspond to step-wise line shapes.</param>
27+
/// <param name="Simplify">Simplifies lines by removing nearly-collinear points. When transitioning lines, it may be desirable to disable this so that the number of points along the resulting SVG path is unaffected.</param>
28+
/// <param name="Smoothing">Has an effect only if `shape` is set to "spline" Sets the amount of smoothing. "0" corresponds to no smoothing (equivalent to a "linear" shape).</param>
29+
/// <param name="Width">Sets the line width (in px).</param>
30+
/// <param name="MultiWidth">Sets the individual line width (in px).</param>
31+
/// <param name="OutlierColor">Sets the color of the outline of outliers</param>
32+
/// <param name="OutlierWidth">Sets the width of the outline of outliers</param>
1233
static member init
1334
(
14-
[<Optional; DefaultParameterValue(null)>] ?Color: Color,
15-
[<Optional; DefaultParameterValue(null)>] ?Width: float,
16-
[<Optional; DefaultParameterValue(null)>] ?MultiWidth: seq<float>,
17-
[<Optional; DefaultParameterValue(null)>] ?Shape: StyleParam.Shape,
18-
[<Optional; DefaultParameterValue(null)>] ?Dash: StyleParam.DrawingStyle,
19-
[<Optional; DefaultParameterValue(null)>] ?Smoothing: float,
20-
[<Optional; DefaultParameterValue(null)>] ?OutlierColor: Color,
21-
[<Optional; DefaultParameterValue(null)>] ?OutlierWidth: float,
2235
[<Optional; DefaultParameterValue(null)>] ?AutoColorScale: bool,
2336
[<Optional; DefaultParameterValue(null)>] ?CAuto: bool,
2437
[<Optional; DefaultParameterValue(null)>] ?CMax: float,
2538
[<Optional; DefaultParameterValue(null)>] ?CMid: float,
2639
[<Optional; DefaultParameterValue(null)>] ?CMin: float,
40+
[<Optional; DefaultParameterValue(null)>] ?Color: Color,
2741
[<Optional; DefaultParameterValue(null)>] ?ColorAxis: StyleParam.SubPlotId,
2842
[<Optional; DefaultParameterValue(null)>] ?Colorscale: StyleParam.Colorscale,
2943
[<Optional; DefaultParameterValue(null)>] ?ReverseScale: bool,
3044
[<Optional; DefaultParameterValue(null)>] ?ShowScale: bool,
31-
[<Optional; DefaultParameterValue(null)>] ?ColorBar: #DynamicObj
45+
[<Optional; DefaultParameterValue(null)>] ?ColorBar: ColorBar,
46+
[<Optional; DefaultParameterValue(null)>] ?Dash: StyleParam.DrawingStyle,
47+
[<Optional; DefaultParameterValue(null)>] ?Shape: StyleParam.Shape,
48+
[<Optional; DefaultParameterValue(null)>] ?Simplify: bool,
49+
[<Optional; DefaultParameterValue(null)>] ?Smoothing: float,
50+
[<Optional; DefaultParameterValue(null)>] ?Width: float,
51+
[<Optional; DefaultParameterValue(null)>] ?MultiWidth: seq<float>,
52+
[<Optional; DefaultParameterValue(null)>] ?OutlierColor: Color,
53+
[<Optional; DefaultParameterValue(null)>] ?OutlierWidth: float
3254
) =
3355
Line()
3456
|> Line.style (
35-
?Color = Color,
36-
?Width = Width,
37-
?MultiWidth = MultiWidth,
38-
?Shape = Shape,
39-
?Dash = Dash,
40-
?Smoothing = Smoothing,
41-
?OutlierColor = OutlierColor,
42-
?OutlierWidth = OutlierWidth,
4357
?AutoColorScale = AutoColorScale,
4458
?CAuto = CAuto,
4559
?CMax = CMax,
4660
?CMid = CMid,
4761
?CMin = CMin,
62+
?Color = Color,
4863
?ColorAxis = ColorAxis,
4964
?Colorscale = Colorscale,
5065
?ReverseScale = ReverseScale,
5166
?ShowScale = ShowScale,
52-
?ColorBar = ColorBar
53-
67+
?ColorBar = ColorBar,
68+
?Dash = Dash,
69+
?Shape = Shape,
70+
?Simplify = Simplify,
71+
?Smoothing = Smoothing,
72+
?Width = Width,
73+
?MultiWidth = MultiWidth,
74+
?OutlierColor = OutlierColor,
75+
?OutlierWidth = OutlierWidth
5476
)
5577

56-
57-
// Applies the styles to Line()
78+
/// <summary>
79+
/// Returns a function that applies the given styles to a Line object.
80+
/// </summary>
81+
/// <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>
82+
/// <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>
83+
/// <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>
84+
/// <param name="CMid">Sets the mid-point of the color domain by scaling `line.cmin` and/or `line.cmax` to be equidistant to this point. Has an effect only if in `line.color`is set to a numerical array. Value should have the same units as in `line.color`. Has no effect when `line.cauto` is `false`.</param>
85+
/// <param name="CMin">Sets the lower 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.cmax` must be set as well.</param>
86+
/// <param name="Color">Sets the line color.</param>
87+
/// <param name="ColorAxis">Sets a reference to a shared color axis. References to these shared color axes are "coloraxis", "coloraxis2", "coloraxis3", etc. Settings for these shared color axes are set in the layout, under `layout.coloraxis`, `layout.coloraxis2`, etc. Note that multiple color scales can be linked to the same color axis.</param>
88+
/// <param name="Colorscale">Sets the line colorscale</param>
89+
/// <param name="ReverseScale">Reverses the color mapping if true.</param>
90+
/// <param name="ShowScale">Wether or not to show the color bar</param>
91+
/// <param name="ColorBar">Sets the colorbar.</param>
92+
/// <param name="Dash">Sets the dash style of lines. Set to a dash type string ("solid", "dot", "dash", "longdash", "dashdot", or "longdashdot") or a dash length list in px (eg "5px,10px,2px,2px").</param>
93+
/// <param name="Shape">Determines the line shape. With "spline" the lines are drawn using spline interpolation. The other available values correspond to step-wise line shapes.</param>
94+
/// <param name="Simplify">Simplifies lines by removing nearly-collinear points. When transitioning lines, it may be desirable to disable this so that the number of points along the resulting SVG path is unaffected.</param>
95+
/// <param name="Smoothing">Has an effect only if `shape` is set to "spline" Sets the amount of smoothing. "0" corresponds to no smoothing (equivalent to a "linear" shape).</param>
96+
/// <param name="Width">Sets the line width (in px).</param>
97+
/// <param name="MultiWidth">Sets the individual line width (in px).</param>
98+
/// <param name="OutlierColor">Sets the color of the outline of outliers</param>
99+
/// <param name="OutlierWidth">Sets the width of the outline of outliers</param>
58100
static member style
59101
(
60-
[<Optional; DefaultParameterValue(null)>] ?Color: Color,
61-
[<Optional; DefaultParameterValue(null)>] ?Width: float,
62-
[<Optional; DefaultParameterValue(null)>] ?MultiWidth: seq<float>,
63-
[<Optional; DefaultParameterValue(null)>] ?Shape: StyleParam.Shape,
64-
[<Optional; DefaultParameterValue(null)>] ?Dash: StyleParam.DrawingStyle,
65-
[<Optional; DefaultParameterValue(null)>] ?Smoothing: float,
66-
[<Optional; DefaultParameterValue(null)>] ?OutlierColor: Color,
67-
[<Optional; DefaultParameterValue(null)>] ?OutlierWidth: float,
68102
[<Optional; DefaultParameterValue(null)>] ?AutoColorScale: bool,
69103
[<Optional; DefaultParameterValue(null)>] ?CAuto: bool,
70104
[<Optional; DefaultParameterValue(null)>] ?CMax: float,
71105
[<Optional; DefaultParameterValue(null)>] ?CMid: float,
72106
[<Optional; DefaultParameterValue(null)>] ?CMin: float,
107+
[<Optional; DefaultParameterValue(null)>] ?Color: Color,
73108
[<Optional; DefaultParameterValue(null)>] ?ColorAxis: StyleParam.SubPlotId,
74109
[<Optional; DefaultParameterValue(null)>] ?Colorscale: StyleParam.Colorscale,
75110
[<Optional; DefaultParameterValue(null)>] ?ReverseScale: bool,
76111
[<Optional; DefaultParameterValue(null)>] ?ShowScale: bool,
77-
[<Optional; DefaultParameterValue(null)>] ?ColorBar: #DynamicObj
112+
[<Optional; DefaultParameterValue(null)>] ?ColorBar: ColorBar,
113+
[<Optional; DefaultParameterValue(null)>] ?Dash: StyleParam.DrawingStyle,
114+
[<Optional; DefaultParameterValue(null)>] ?Shape: StyleParam.Shape,
115+
[<Optional; DefaultParameterValue(null)>] ?Simplify: bool,
116+
[<Optional; DefaultParameterValue(null)>] ?Smoothing: float,
117+
[<Optional; DefaultParameterValue(null)>] ?Width: float,
118+
[<Optional; DefaultParameterValue(null)>] ?MultiWidth: seq<float>,
119+
[<Optional; DefaultParameterValue(null)>] ?OutlierColor: Color,
120+
[<Optional; DefaultParameterValue(null)>] ?OutlierWidth: float
78121
) =
79122
(fun (line: Line) ->
80123
Color |> DynObj.setValueOpt line "color"
@@ -95,6 +138,6 @@ type Line() =
95138
ReverseScale |> DynObj.setValueOpt line "reversescale"
96139
ShowScale |> DynObj.setValueOpt line "showscale"
97140
ColorBar |> DynObj.setValueOpt line "colorbar"
141+
Simplify |> DynObj.setValueOpt line "simplify"
98142

99-
// out ->
100143
line)

0 commit comments

Comments
 (0)