Skip to content

Commit 417b88f

Browse files
committed
#137: Add all Bar trace parameters
1 parent 4e2475a commit 417b88f

3 files changed

Lines changed: 147 additions & 30 deletions

File tree

src/Plotly.NET/CommonAbstractions/StyleParams.fs

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,23 @@ module StyleParam =
289289
// #C#
290290
//--------------------------
291291

292+
[<RequireQualifiedAccess>]
293+
type ConstrainText =
294+
| Inside
295+
| Outside
296+
| Both
297+
| None
298+
299+
static member toString = function
300+
| Inside -> "inside"
301+
| Outside -> "outside"
302+
| Both -> "both"
303+
| None -> "none"
304+
305+
static member convert = ConstrainText.toString >> box
306+
override this.ToString() = this |> ConstrainText.toString
307+
member this.Convert() = this |> ConstrainText.convert
308+
292309
[<RequireQualifiedAccess>]
293310
type ClickMode =
294311
| Event
@@ -962,8 +979,18 @@ module StyleParam =
962979
// #I#
963980
//--------------------------
964981

982+
[<RequireQualifiedAccess>]
983+
type InsideTextAnchor =
984+
| End | Middle | Start
985+
static member toString = function
986+
| End -> "end"
987+
| Middle -> "middle"
988+
| Start -> "start"
965989

966-
990+
static member convert = InsideTextAnchor.toString >> box
991+
override this.ToString() = this |> InsideTextAnchor.toString
992+
member this.Convert() = this |> InsideTextAnchor.convert
993+
967994
[<RequireQualifiedAccess>]
968995
type InsideTextOrientation =
969996
| Horizontal | Radial | Tangential | Auto

src/Plotly.NET/Playground.fsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ open FSharpAux
147147

148148
open System
149149

150+
let products = ["Product A"; "Product B"; "Product C"];
151+
let sfValues = [20; 14; 23]
152+
Chart.Column ( products,
153+
sfValues,
154+
Labels= sfValues,
155+
TextPosition = StyleParam.TextPosition.Inside
156+
)
157+
|> Chart.show
158+
150159
let doughnutChart =
151160
let values = [19; 26; 55;]
152161
let labels = ["Residential"; "Non-Residential"; "Utility"]
@@ -160,7 +169,7 @@ let doughnutChart =
160169

161170
Chart.Doughnut(
162171
values = [10; 15; 15; 30; 22],
163-
labels = ["some"; "random"; "slice"; "labels"; "bruh"],
172+
Labels = ["some"; "random"; "slice"; "labels"; "bruh"],
164173
TextLabels = ["text"; "labels"; "are"; "different"; "thing"],
165174
TextPosition = StyleParam.TextPosition.Outside,
166175
Direction = StyleParam.Direction.CounterClockwise,

src/Plotly.NET/Traces/Trace2D.fs

Lines changed: 109 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -303,38 +303,119 @@ type Trace2DStyle() =
303303
)
304304

305305
/// <summary>Create a function that applies the styles of a bar plot to a Trace object</summary>
306-
/// <param name="X">Sets the x coordinates of the plotted data.</param>
307-
/// <param name="Y">Sets the y coordinates of the plotted data.</param>
308-
/// <param name="Marker">Sets Marker</param>
309-
/// <param name="Orientation">Sets the stacking direction. Only relevant when `stackgroup` is used, and only the first `orientation` found in the `stackgroup` will be used.</param>
310-
/// <param name="R">[Legacy] used for polar charts. Will be removed when adding the new polar charts.</param>
311-
/// <param name="T">[Legacy] used for polar charts. Will be removed when adding the new polar charts.</param>
312-
/// <param name="Error_y">Sets vertical error bars for this this scatter trace.</param>
313-
/// <param name="Error_x">Sets horizontal error bars for this this scatter trace.</param>
314306
static member Bar
315307
(
316-
[<Optional;DefaultParameterValue(null)>] ?X : seq<#IConvertible>,
317-
[<Optional;DefaultParameterValue(null)>] ?Y : seq<#IConvertible>,
318-
[<Optional;DefaultParameterValue(null)>] ?Marker : Marker,
319-
[<Optional;DefaultParameterValue(null)>] ?R : seq<#IConvertible>,
320-
[<Optional;DefaultParameterValue(null)>] ?T : seq<#IConvertible>,
321-
[<Optional;DefaultParameterValue(null)>] ?Error_y: Error,
322-
[<Optional;DefaultParameterValue(null)>] ?Error_x: Error,
323-
[<Optional;DefaultParameterValue(null)>] ?Orientation
308+
[<Optional;DefaultParameterValue(null)>] ?Name : string,
309+
[<Optional;DefaultParameterValue(null)>] ?Visible : StyleParam.Visible,
310+
[<Optional;DefaultParameterValue(null)>] ?ShowLegend : bool,
311+
[<Optional;DefaultParameterValue(null)>] ?LegendRank : int,
312+
[<Optional;DefaultParameterValue(null)>] ?LegendGroup : string,
313+
[<Optional;DefaultParameterValue(null)>] ?LegendGroupTitle : Title,
314+
[<Optional;DefaultParameterValue(null)>] ?Opacity : float,
315+
[<Optional;DefaultParameterValue(null)>] ?Ids : seq<#IConvertible>,
316+
[<Optional;DefaultParameterValue(null)>] ?X : seq<#IConvertible>,
317+
[<Optional;DefaultParameterValue(null)>] ?X0 : #IConvertible,
318+
[<Optional;DefaultParameterValue(null)>] ?DX : #IConvertible,
319+
[<Optional;DefaultParameterValue(null)>] ?Y : seq<#IConvertible>,
320+
[<Optional;DefaultParameterValue(null)>] ?Y0 : #IConvertible,
321+
[<Optional;DefaultParameterValue(null)>] ?DY : #IConvertible,
322+
[<Optional;DefaultParameterValue(null)>] ?Base : #IConvertible,
323+
[<Optional;DefaultParameterValue(null)>] ?Text : seq<#IConvertible>,
324+
[<Optional;DefaultParameterValue(null)>] ?TextPosition : StyleParam.TextPosition,
325+
[<Optional;DefaultParameterValue(null)>] ?TextTemplate : string,
326+
[<Optional;DefaultParameterValue(null)>] ?HoverText : string,
327+
[<Optional;DefaultParameterValue(null)>] ?HoverInfo : StyleParam.HoverInfo,
328+
[<Optional;DefaultParameterValue(null)>] ?HoverTemplate : string,
329+
[<Optional;DefaultParameterValue(null)>] ?XHoverFormat : string,
330+
[<Optional;DefaultParameterValue(null)>] ?YHoverFormat : string,
331+
[<Optional;DefaultParameterValue(null)>] ?Meta : string,
332+
[<Optional;DefaultParameterValue(null)>] ?CustomData : seq<#IConvertible>,
333+
[<Optional;DefaultParameterValue(null)>] ?XAxis : StyleParam.LinearAxisId,
334+
[<Optional;DefaultParameterValue(null)>] ?YAxis : StyleParam.LinearAxisId,
335+
[<Optional;DefaultParameterValue(null)>] ?Orientation : StyleParam.Orientation,
336+
[<Optional;DefaultParameterValue(null)>] ?AlignmentGroup : string,
337+
[<Optional;DefaultParameterValue(null)>] ?OffsetGroup : string,
338+
[<Optional;DefaultParameterValue(null)>] ?XPeriod : #IConvertible,
339+
[<Optional;DefaultParameterValue(null)>] ?XPeriodAlignment : StyleParam.PeriodAlignment,
340+
[<Optional;DefaultParameterValue(null)>] ?XPeriod0 : #IConvertible,
341+
[<Optional;DefaultParameterValue(null)>] ?YPeriod : #IConvertible,
342+
[<Optional;DefaultParameterValue(null)>] ?YPeriodAlignment : StyleParam.PeriodAlignment,
343+
[<Optional;DefaultParameterValue(null)>] ?YPeriod0 : #IConvertible,
344+
[<Optional;DefaultParameterValue(null)>] ?Marker : Marker,
345+
[<Optional;DefaultParameterValue(null)>] ?TextAngle : float,
346+
[<Optional;DefaultParameterValue(null)>] ?TextFont : Font,
347+
[<Optional;DefaultParameterValue(null)>] ?ErrorX : Error,
348+
[<Optional;DefaultParameterValue(null)>] ?ErrorY : Error,
349+
[<Optional;DefaultParameterValue(null)>] ?SelectedPoints : seq<#IConvertible>,
350+
[<Optional;DefaultParameterValue(null)>] ?Selected : Selection,
351+
[<Optional;DefaultParameterValue(null)>] ?Unselected : Selection,
352+
[<Optional;DefaultParameterValue(null)>] ?ClipOnAxis : bool,
353+
[<Optional;DefaultParameterValue(null)>] ?Constraintext : StyleParam.ConstrainText,
354+
[<Optional;DefaultParameterValue(null)>] ?HoverLabel : Hoverlabel,
355+
[<Optional;DefaultParameterValue(null)>] ?InsideTextAnchor : StyleParam.InsideTextAnchor,
356+
[<Optional;DefaultParameterValue(null)>] ?InsideTextFont : Font,
357+
[<Optional;DefaultParameterValue(null)>] ?OutsideTextFont : Font,
358+
[<Optional;DefaultParameterValue(null)>] ?XCalendar : StyleParam.Calendar,
359+
[<Optional;DefaultParameterValue(null)>] ?YCalendar : StyleParam.Calendar,
360+
[<Optional;DefaultParameterValue(null)>] ?UIRevision : string
361+
324362
) =
325363
(fun (bar:('T :> Trace)) ->
326-
X |> DynObj.setValueOpt bar "x"
327-
Y |> DynObj.setValueOpt bar "y"
328-
R |> DynObj.setValueOpt bar "r"
329-
T |> DynObj.setValueOpt bar "t"
330-
Orientation |> DynObj.setValueOptBy bar "orientation" StyleParam.Orientation.convert
331-
332-
// Update
333-
Marker |> DynObj.setValueOpt bar "marker"
334-
Error_x |> DynObj.setValueOpt bar "error_x"
335-
Error_y |> DynObj.setValueOpt bar "error_y"
336-
337-
// out ->
364+
365+
Name |> DynObj.setValueOpt bar "name"
366+
Visible |> DynObj.setValueOptBy bar "visible" StyleParam.Visible.convert
367+
ShowLegend |> DynObj.setValueOpt bar "showlegend"
368+
LegendRank |> DynObj.setValueOpt bar "legendrank"
369+
LegendGroup |> DynObj.setValueOpt bar "legendgroup"
370+
LegendGroupTitle |> DynObj.setValueOpt bar "legendgrouptitle"
371+
Opacity |> DynObj.setValueOpt bar "opacity"
372+
Ids |> DynObj.setValueOpt bar "ids"
373+
X |> DynObj.setValueOpt bar "x"
374+
X0 |> DynObj.setValueOpt bar "x0"
375+
DX |> DynObj.setValueOpt bar "dx"
376+
Y |> DynObj.setValueOpt bar "y"
377+
Y0 |> DynObj.setValueOpt bar "y0"
378+
DY |> DynObj.setValueOpt bar "dy"
379+
Base |> DynObj.setValueOpt bar "base"
380+
Text |> DynObj.setValueOpt bar "text"
381+
TextPosition |> DynObj.setValueOptBy bar "textposition" StyleParam.TextPosition.convert
382+
TextTemplate |> DynObj.setValueOpt bar "texttemplate"
383+
HoverText |> DynObj.setValueOpt bar "hovertext"
384+
HoverInfo |> DynObj.setValueOptBy bar "hoverinfo" StyleParam.HoverInfo.convert
385+
HoverTemplate |> DynObj.setValueOpt bar "hovertemplate"
386+
XHoverFormat |> DynObj.setValueOpt bar "xhoverformat"
387+
YHoverFormat |> DynObj.setValueOpt bar "yhoverformat"
388+
Meta |> DynObj.setValueOpt bar "meta"
389+
CustomData |> DynObj.setValueOpt bar "customdata"
390+
XAxis |> DynObj.setValueOptBy bar "xaxis" StyleParam.LinearAxisId.convert
391+
YAxis |> DynObj.setValueOptBy bar "yaxis" StyleParam.LinearAxisId.convert
392+
Orientation |> DynObj.setValueOptBy bar "orientation" StyleParam.Orientation.convert
393+
AlignmentGroup |> DynObj.setValueOpt bar "alignmentgroup"
394+
OffsetGroup |> DynObj.setValueOpt bar "offsetgroup"
395+
XPeriod |> DynObj.setValueOpt bar "xperiod"
396+
XPeriodAlignment |> DynObj.setValueOptBy bar "xperiodalignment" StyleParam.PeriodAlignment.convert
397+
XPeriod0 |> DynObj.setValueOpt bar "xperiod0"
398+
YPeriod |> DynObj.setValueOpt bar "yperiod"
399+
YPeriodAlignment |> DynObj.setValueOptBy bar "yperiodalignment" StyleParam.PeriodAlignment.convert
400+
YPeriod0 |> DynObj.setValueOpt bar "yperiod0"
401+
Marker |> DynObj.setValueOpt bar "marker"
402+
TextAngle |> DynObj.setValueOpt bar "textangle"
403+
TextFont |> DynObj.setValueOpt bar "textfont"
404+
ErrorX |> DynObj.setValueOpt bar "errorx"
405+
ErrorY |> DynObj.setValueOpt bar "errory"
406+
SelectedPoints |> DynObj.setValueOpt bar "selectedpoints"
407+
Selected |> DynObj.setValueOpt bar "selected"
408+
Unselected |> DynObj.setValueOpt bar "unselected"
409+
ClipOnAxis |> DynObj.setValueOpt bar "cliponaxis"
410+
Constraintext |> DynObj.setValueOptBy bar "constraintext" StyleParam.ConstrainText.convert
411+
HoverLabel |> DynObj.setValueOpt bar "hoverlabel"
412+
InsideTextAnchor |> DynObj.setValueOptBy bar "insidetextanchor" StyleParam.InsideTextAnchor.convert
413+
InsideTextFont |> DynObj.setValueOpt bar "insidetextfont"
414+
OutsideTextFont |> DynObj.setValueOpt bar "outsidetextfont"
415+
XCalendar |> DynObj.setValueOptBy bar "xcalendar" StyleParam.Calendar.convert
416+
YCalendar |> DynObj.setValueOptBy bar "ycalendar" StyleParam.Calendar.convert
417+
UIRevision |> DynObj.setValueOpt bar "uirevision"
418+
338419
bar
339420

340421
)

0 commit comments

Comments
 (0)