diff --git a/src/Plotly.NET/Chart.fs b/src/Plotly.NET/Chart.fs index 52636ca88..22b10110a 100644 --- a/src/Plotly.NET/Chart.fs +++ b/src/Plotly.NET/Chart.fs @@ -1995,7 +1995,7 @@ type Chart = |> GenericChart.ofTraceObject /// Creates a Funnel chart. - /// Funnel charts Visualize stages in a process using length-encoded bars. This trace can be used to show data in either a part-to-whole representation wherein each item appears in a single stage, or in a "drop-off" representation wherein each item appears in each stage it traversed. See also the "funnelarea" trace type for a different approach to visualizing funnel data. + /// Funnel charts visualize stages in a process using length-encoded bars. This trace can be used to show data in either a part-to-whole representation wherein each item appears in a single stage, or in a "drop-off" representation wherein each item appears in each stage it traversed. See also the "funnelarea" trace type for a different approach to visualizing funnel data. /// /// Parameters: /// @@ -2092,6 +2092,89 @@ type Chart = |> TraceStyle.TextLabel(?Text=Labels,?Textposition=TextPosition,?Textfont=TextFont) |> GenericChart.ofTraceObject + /// Creates a FunnelArea chart. + /// FunnelArea charts visualize stages in a process using area-encoded trapezoids. This trace can be used to show data in a part-to-whole representation similar to a "pie" trace, wherein each item appears in a single stage. See also the "funnel" trace type for a different approach to visualizing funnel data. + /// + /// Parameters: + /// + /// Values : Sets the values of the sectors. If omitted, we count occurrences of each label. + /// + /// Labels : Sets the sector labels. If `labels` entries are duplicated, we sum associated `values` or simply count occurrences if `values` is not provided. For other array attributes (including color) we use the first non-empty entry among all occurrences of the label. + /// + /// dLabel : Sets the label step. See `label0` for more info. + /// + /// Label0 : Alternate to `labels`. Builds a numeric set of labels. Use with `dlabel` where `label0` is the starting label and `dlabel` the step. + /// + /// Name : Sets the trace name. The trace name appear as the legend item and on hover. + /// + /// Showlegend : Determines whether or not an item corresponding to this trace is shown in the legend. + /// + /// Opacity : Sets the opacity of the trace. + /// + /// Color : Sets Marker Color + /// + /// Line : Line type + /// + /// Text : Sets text elements associated with each sector. If trace `textinfo` contains a "text" flag, these elements will be seen on the chart. If trace `hoverinfo` contains a "text" flag and "hovertext" is not set, these elements will be seen in the hover labels. + /// + /// TextPosition : Specifies the location of the `textinfo`. + /// + /// X : Sets the horizontal domain of this funnelarea trace (in plot fraction). + /// + /// Y : Sets the vertical domain of this funnelarea trace (in plot fraction). + /// + /// Row : If there is a layout grid, use the domain for this row in the grid for this funnelarea trace . + /// + /// Column : If there is a layout grid, use the domain for this column in the grid for this funnelarea trace . + /// + /// Aspectratio : Sets the ratio between height and width + /// + /// Baseratio : Sets the ratio between bottom length and maximum top length. + /// + /// Insidetextfont: Sets the font used for `textinfo` lying inside the sector. + /// + /// Scalegroup : If there are multiple funnelareas that should be sized according to their totals, link them by providing a non-empty group id here shared by every trace in the same group. + static member FunnelArea + ( + [] ?Values , + [] ?Labels , + [] ?dLabel , + [] ?Label0 , + [] ?Name , + [] ?Showlegend , + [] ?Opacity , + [] ?Color , + [] ?Line , + [] ?Text , + [] ?TextPosition , + [] ?X , + [] ?Y , + [] ?Row , + [] ?Column , + [] ?Aspectratio , + [] ?Baseratio , + [] ?Insidetextfont, + [] ?Scalegroup + ) = + + Trace.initFunnelArea( + TraceStyle.FunnelArea( + ?Values = Values , + ?Labels = Labels , + ?dLabel = dLabel , + ?Label0 = Label0 , + ?Aspectratio = Aspectratio , + ?Baseratio = Baseratio , + ?Insidetextfont = Insidetextfont, + ?Scalegroup = Scalegroup + ) + ) + |> TraceStyle.TraceInfo(?Name=Name,?Showlegend=Showlegend,?Opacity=Opacity) + |> TraceStyle.Marker(?Color=Color,?Line=Line) + |> TraceStyle.Domain(?X=X,?Y=Y,?Row=Row,?Column=Column) + |> TraceStyle.TextLabel(?Text=Text,?Textposition=TextPosition) + |> GenericChart.ofTraceObject + /// Creates a ScatterGeo chart, where data is visualized on a geographic map. /// ScatterGeo charts are the basis of GeoPoint, GeoLine, and GeoBubble Charts, and can be customized as such. We also provide abstractions for those: Chart.GeoPoint, Chart.GeoLine, Chart.GeoBubble /// diff --git a/src/Plotly.NET/Playground.fsx b/src/Plotly.NET/Playground.fsx index 23498ec89..4f34aa5d1 100644 --- a/src/Plotly.NET/Playground.fsx +++ b/src/Plotly.NET/Playground.fsx @@ -572,7 +572,7 @@ let doughnut1 = ) |> Chart.Show -// Funnel example adapted from Plotly docs: https://plotly.com/javascript/funnel-charts/ +// Funnel examples adapted from Plotly docs: https://plotly.com/javascript/funnel-charts/ let funnel = let y = [|"Sales person A"; "Sales person B"; "Sales person C"; "Sales person D"; "Sales person E"|] let x = [|1200.; 909.4; 600.6; 300.; 80.|] @@ -581,4 +581,16 @@ let funnel = let connector = FunnelConnector.init(Line=connectorLine) Chart.Funnel (x,y,Color="59D4E8", Line=line, Connector=connector) |> Chart.withMarginSize(Left=100) + |> Chart.Show + +let funnelArea = + let values = [|5; 4; 3; 2; 1|] + let text = [|"The 1st"; "The 2nd"; "The 3rd"; "The 4th"; "The 5th"|] + let line = Line.init (Color="purple", Width=3.) + Chart.FunnelArea(Values=values, Text=text, Line=line) + |> Chart.Show + +let funnelArea2 = + let labels = [|1;2;2;3;3;3|] + Chart.FunnelArea(Labels=labels) |> Chart.Show \ No newline at end of file diff --git a/src/Plotly.NET/Trace.fs b/src/Plotly.NET/Trace.fs index 0be296803..10dcbb53c 100644 --- a/src/Plotly.NET/Trace.fs +++ b/src/Plotly.NET/Trace.fs @@ -374,6 +374,37 @@ module Trace = ) + /// Sets the given domain on a Trace object. + static member SetDomain + ( + domain:Domain + ) = + (fun (trace:('T :> Trace)) -> + + trace.SetValue("domain", domain) + trace + ) + + /// Sets the given Domain styles on the domain property of a Trace object + static member Domain + ( + ?X : StyleParam.Range, + ?Y : StyleParam.Range, + ?Row : int, + ?Column: int + ) = + (fun (trace:('T :> Trace)) -> + let domain = + match (trace.TryGetValue "domain") with + | Some m -> m :?> Domain + | None -> Domain () + + |> Domain.style(?X=X,?Y=Y,?Row=Row,?Column=Column) + + trace.SetValue("domain", domain) + trace + ) + // Sets the X-Error an a Trace object. static member SetErrorX ( @@ -1477,7 +1508,33 @@ module Trace = Cliponaxis |> DynObj.setValueOpt trace "cliponaxis" Connector |> DynObj.setValueOpt trace "connector" Insidetextfont |> DynObj.setValueOpt trace "insidetextfont" - Outsidetextfont |> DynObj.setValueOpt trace "insidetextfont" + Outsidetextfont |> DynObj.setValueOpt trace "outsidetextfont" + + trace + + ) + + static member FunnelArea + ( + ?Values : seq<#IConvertible>, + ?Labels : seq<#IConvertible>, + ?dLabel : float, + ?Label0 : float, + ?Aspectratio : float, + ?Baseratio : float, + ?Insidetextfont: Font, + ?Scalegroup : string + ) = + (fun (trace:('T :> Trace)) -> + + Values |> DynObj.setValueOpt trace "values" + Labels |> DynObj.setValueOpt trace "labels" + dLabel |> DynObj.setValueOpt trace "dlabel" + Label0 |> DynObj.setValueOpt trace "label0" + Aspectratio |> DynObj.setValueOpt trace "aspectratio" + Baseratio |> DynObj.setValueOpt trace "baseratio" + Insidetextfont |> DynObj.setValueOpt trace "insidetextfont" + Scalegroup |> DynObj.setValueOpt trace "scalegroup" trace