Skip to content

Commit af74487

Browse files
committed
Add: Pie and doughnut charts
1 parent f52ba52 commit af74487

File tree

3 files changed

+35
-22
lines changed

3 files changed

+35
-22
lines changed

docs/content/pie-daughnut-charts.fsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ Chart.Pie(values,labels)
2222
(*** include-it:pie1 ***)
2323

2424
(*** define-output:doughnut1 ***)
25-
Chart.Doughnut(values,labels,Hole=0.3)
25+
Chart.Doughnut(values,labels,Hole=0.3,Text=labels)
2626
(*** include-it:doughnut1 ***)
27+
|> Chart.Show
28+
29+

src/FSharp.Plotly/Chart.fs

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -307,28 +307,38 @@ type Chart =
307307
GenericChart.Chart (trace,None)
308308

309309

310-
// /// Shows how proportions of data, shown as pie-shaped pieces, contribute to the data as a whole.
311-
// static member Pie(values,?labels,?Name,?Showlegend,?Color,?Hoverinfo,?Textinfo,?Textposition) =
312-
// let trace =
313-
// Pie()
314-
// |> Options.Pie(Values=values,?Labels=labels,
315-
// TraceOptions=Options.Trace(?Name=Name,?Showlegend=Showlegend,?Hoverinfo=Hoverinfo),
316-
// Marker=Options.Marker(?Color=Color),
317-
// ?Textinfo=Textinfo,?Textposition=Textposition)
318-
// GenericChart.Chart (trace,None)
310+
/// Shows how proportions of data, shown as pie-shaped pieces, contribute to the data.
311+
static member Pie(values,?Labels,?Name,?Showlegend,?Color,?Text,?Textposition,?TextFont,?Hoverinfo,?Textinfo,?Opacity) =
312+
let trace =
313+
Pie()
314+
|> Options.Pie(Values=values,?Labels=Labels,?Textinfo=Textinfo)
315+
|> Options.ITraceInfo(?Name=Name,?Showlegend=Showlegend,?Opacity=Opacity,?Hoverinfo=Hoverinfo)
316+
|> Options.ITextLabel(?Text=Text,?Textposition=Textposition,?Textfont=TextFont)
317+
|> Options.IMarker(Marker=Options.Marker(?Color=Color))
318+
319+
GenericChart.Chart (trace,None)
319320

321+
/// Shows how proportions of data, shown as pie-shaped pieces, contribute to the data.
322+
static member Pie(data:seq<#IConvertible*#IConvertible>,?Name,?Showlegend,?Color,?Text,?Textposition,?TextFont,?Hoverinfo,?Textinfo,?Opacity) =
323+
let values,labels = Seq.unzip data
324+
Chart.Pie(values,Labels=labels,?Name=Name,?Showlegend=Showlegend,?Color=Color,?Text=Text,?Textposition=Textposition,?TextFont=TextFont,?Hoverinfo=Hoverinfo,?Textinfo=Textinfo,?Opacity=Opacity)
320325

321-
// /// Shows how proportions of data, shown as pie-shaped pieces, contribute to the data as a whole.
322-
// static member Doughnut(values,?labels,?Name,?Showlegend,?Color,?Hole,?Hoverinfo,?Textinfo,?Textposition) =
323-
// let hole' = if Hole.IsSome then Hole.Value else 0.4
324-
// let trace =
325-
// Pie()
326-
// |> Options.Pie(Values=values,?Labels=labels,
327-
// TraceOptions=Options.Trace(?Name=Name,?Showlegend=Showlegend,?Hoverinfo=Hoverinfo),
328-
// Marker=Options.Marker(?Color=Color),
329-
// ?Textinfo=Textinfo,?Textposition=Textposition,Hole=hole')
330-
// GenericChart.Chart (trace,None)
326+
/// Shows how proportions of data, shown as pie-shaped pieces, contribute to the data as a whole.
327+
static member Doughnut(values,?Labels,?Name,?Showlegend,?Color,?Hole,?Text,?Textposition,?TextFont,?Hoverinfo,?Textinfo,?Opacity) =
328+
let hole' = if Hole.IsSome then Hole.Value else 0.4
329+
let trace =
330+
Pie()
331+
|> Options.Pie(Values=values,?Labels=Labels,?Textinfo=Textinfo,Hole=hole')
332+
|> Options.ITraceInfo(?Name=Name,?Showlegend=Showlegend,?Opacity=Opacity,?Hoverinfo=Hoverinfo)
333+
|> Options.ITextLabel(?Text=Text,?Textposition=Textposition,?Textfont=TextFont)
334+
|> Options.IMarker(Marker=Options.Marker(?Color=Color))
335+
336+
GenericChart.Chart (trace,None)
331337

338+
/// Shows how proportions of data, shown as pie-shaped pieces, contribute to the data as a whole.
339+
static member Doughnut(data:seq<#IConvertible*#IConvertible>,?Name,?Showlegend,?Color,?Hole,?Text,?Textposition,?TextFont,?Hoverinfo,?Textinfo,?Opacity) =
340+
let values,labels = Seq.unzip data
341+
Chart.Doughnut(values,Labels=labels,?Name=Name,?Showlegend=Showlegend,?Color=Color,?Hole=Hole,?Text=Text,?Textposition=Textposition,?TextFont=TextFont,?Hoverinfo=Hoverinfo,?Textinfo=Textinfo,?Opacity=Opacity)
332342

333343

334344

src/FSharp.Plotly/Options.fs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ type Options() =
599599
?dLabel,
600600
?Scalegroup,
601601
?Textinfo,
602-
?Textfont: FontOptions,
602+
//?Textfont: FontOptions,
603603
?Insidetextfont: FontOptions,
604604
?Outsidetextfont: FontOptions,
605605
?Domain, // TODO
@@ -634,7 +634,7 @@ type Options() =
634634

635635
// Update
636636
//Marker |> Option.iter (updatePropertyValueAndIgnore pie <@ pie.marker @>)
637-
Textfont |> Option.iter (updatePropertyValueAndIgnore pie <@ pie.textfont @>)
637+
//Textfont |> Option.iter (updatePropertyValueAndIgnore pie <@ pie.textfont @>)
638638
Insidetextfont |> Option.iter (updatePropertyValueAndIgnore pie <@ pie.insidetextfont @>)
639639
Outsidetextfont |> Option.iter (updatePropertyValueAndIgnore pie <@ pie.outsidetextfont @>)
640640

0 commit comments

Comments
 (0)