Pie and doughnut Charts

BinderScriptNotebook

Summary: This example shows how to create pie and doughnut charts in F#.

let's first create some data for the purpose of creating example charts:

open Plotly.NET 
  
let values = [19; 26; 55;]
let labels = ["Residential"; "Non-Residential"; "Utility"]

A pie, doughnut, or sunburst chart can be created using the Chart.Pie, Chart.Doughnut, and Chart.Sunburst functions. When creating pie charts, it is usually desirable to provide both labels and values.

let pie1 =
    Chart.Pie(values,labels)
let doughnut1 =
    Chart.Doughnut(
        values,
        labels,
        Hole=0.3,
        Textinfo=labels
    )
let sunburst1 =
    Chart.Sunburst(
        ["A";"B";"C";"D";"E"],
        ["";"";"B";"B";""],
        Values=[5.;0.;3.;2.;3.],
        Text=["At";"Bt";"Ct";"Dt";"Et"]
    )
namespace Plotly
namespace Plotly.NET
val values : int list
val labels : string list
val pie1 : GenericChart.GenericChart
type Chart =
  static member Area : x:seq<#IConvertible> * y:seq<#IConvertible> * ?Name:string * ?ShowMarkers:bool * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:string * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Dash:DrawingStyle * ?Width:float -> GenericChart + 1 overload
  static member Bar : keys:seq<#IConvertible> * values:seq<#IConvertible> * ?Name:string * ?Showlegend:bool * ?Color:string * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Marker:Marker -> GenericChart + 1 overload
  static member BoxPlot : ?x:'a0 * ?y:'a1 * ?Name:string * ?Showlegend:bool * ?Color:string * ?Fillcolor:'a2 * ?Opacity:float * ?Whiskerwidth:'a3 * ?Boxpoints:Boxpoints * ?Boxmean:BoxMean * ?Jitter:'a4 * ?Pointpos:'a5 * ?Orientation:Orientation * ?Marker:Marker * ?Line:Line * ?Alignmentgroup:'a6 * ?Offsetgroup:'a7 * ?Notched:bool * ?NotchWidth:float * ?QuartileMethod:QuartileMethod -> GenericChart + 1 overload
  static member Bubble : x:seq<#IConvertible> * y:seq<#IConvertible> * sizes:seq<#IConvertible> * ?Name:string * ?Showlegend:bool * ?MarkerSymbol:Symbol * ?Color:string * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?StackGroup:string * ?Orientation:Orientation * ?GroupNorm:GroupNorm * ?UseWebGL:bool -> GenericChart + 1 overload
  static member Candlestick : open:seq<#IConvertible> * high:seq<#IConvertible> * low:seq<#IConvertible> * close:seq<#IConvertible> * x:seq<#IConvertible> * ?Increasing:Line * ?Decreasing:Line * ?WhiskerWidth:float * ?Line:Line * ?XCalendar:Calendar -> GenericChart + 1 overload
  static member ChoroplethMap : locations:seq<string> * z:seq<#IConvertible> * ?Text:seq<#IConvertible> * ?Locationmode:LocationFormat * ?Autocolorscale:bool * ?Colorscale:Colorscale * ?Colorbar:'a2 * ?Marker:Marker * ?Zmin:'a3 * ?Zmax:'a4 -> GenericChart
  static member Column : keys:seq<#IConvertible> * values:seq<#IConvertible> * ?Name:string * ?Showlegend:bool * ?Color:string * ?Opacity:float * ?Labels:seq<#IConvertible> * ?TextPosition:TextPosition * ?TextFont:Font * ?Marker:Marker -> GenericChart + 1 overload
  static member Contour : data:seq<#seq<'a1>> * ?X:seq<#IConvertible> * ?Y:seq<#IConvertible> * ?Name:string * ?Showlegend:bool * ?Opacity:float * ?Colorscale:Colorscale * ?Showscale:'a4 * ?zSmooth:SmoothAlg * ?Colorbar:'a5 -> GenericChart (requires 'a1 :> IConvertible)
  static member Doughnut : values:seq<#IConvertible> * ?Labels:seq<#IConvertible> * ?Name:string * ?Showlegend:bool * ?Colors:seq<string> * ?Hole:float * ?TextPosition:TextPosition * ?TextFont:Font * ?Hoverinfo:string * ?Textinfo:'c * ?Opacity:float -> GenericChart + 1 overload
  static member Heatmap : data:seq<#seq<'a1>> * ?ColNames:seq<#IConvertible> * ?RowNames:seq<#IConvertible> * ?Name:string * ?Showlegend:bool * ?Opacity:float * ?Colorscale:Colorscale * ?Showscale:'a4 * ?Xgap:'a5 * ?Ygap:'a6 * ?zSmooth:SmoothAlg * ?Colorbar:'a7 * ?UseWebGL:bool -> GenericChart (requires 'a1 :> IConvertible)
  ...
static member Chart.Pie : data:seq<#System.IConvertible * #System.IConvertible> * ?Name:string * ?Showlegend:bool * ?Colors:seq<string> * ?TextPosition:StyleParam.TextPosition * ?TextFont:Font * ?Hoverinfo:string * ?Textinfo:'a2 * ?Opacity:float -> GenericChart.GenericChart
static member Chart.Pie : values:seq<#System.IConvertible> * ?Labels:seq<#System.IConvertible> * ?Name:string * ?Showlegend:bool * ?Colors:seq<string> * ?TextPosition:StyleParam.TextPosition * ?TextFont:Font * ?Hoverinfo:string * ?Textinfo:'b * ?Opacity:float -> GenericChart.GenericChart
module GenericChart

from Plotly.NET
val toChartHTML : gChart:GenericChart.GenericChart -> string
val doughnut1 : GenericChart.GenericChart
static member Chart.Doughnut : data:seq<#System.IConvertible * #System.IConvertible> * ?Name:string * ?Showlegend:bool * ?Colors:seq<string> * ?Hole:float * ?TextPosition:StyleParam.TextPosition * ?TextFont:Font * ?Hoverinfo:string * ?Textinfo:'a2 * ?Opacity:float -> GenericChart.GenericChart
static member Chart.Doughnut : values:seq<#System.IConvertible> * ?Labels:seq<#System.IConvertible> * ?Name:string * ?Showlegend:bool * ?Colors:seq<string> * ?Hole:float * ?TextPosition:StyleParam.TextPosition * ?TextFont:Font * ?Hoverinfo:string * ?Textinfo:'c * ?Opacity:float -> GenericChart.GenericChart
val sunburst1 : GenericChart.GenericChart
static member Chart.Sunburst : labels:seq<#System.IConvertible> * parents:seq<#System.IConvertible> * ?Ids:seq<string> * ?Values:seq<float> * ?Text:seq<string> * ?Branchvalues:StyleParam.BranchValues * ?Level:'c * ?Maxdepth:int * ?Colors:seq<string> * ?Colorbar:Colorbar -> GenericChart.GenericChart