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 = labels)
let doughnut1 =
Chart.Doughnut(
values,
Labels = labels,
Hole=0.3,
MultiText = labels
)
This example shows the usage of some of the styling possibility using Chart.Pie
.
For even more styling control, use the respective TraceStyle function TraceDomainStyle.Pie
let pieStyled =
let values = [19; 26; 55;]
let labels = ["Residential"; "Non-Residential"; "Utility"]
Chart.Pie(
values,
Labels = labels,
SectionColors = [
Color.fromKeyword Aqua
Color.fromKeyword Salmon
Color.fromKeyword Tan
],
SectionOutlineColor = Color.fromKeyword Black,
SectionOutlineWidth = 2.,
MultiText = [
"Some"
"More"
"Stuff"
],
MultiTextPosition = [
StyleParam.TextPosition.Inside
StyleParam.TextPosition.Outside
StyleParam.TextPosition.Inside
],
Rotation = 45.,
MultiPull = [0.; 0.3; 0.]
)