Home
Insert
Update snippet 'Doughnut chart using chart controls'
Title
Description
The snippet shows how to use Microsoft Chart Controls (available in .NET 4.0 and for .NET 3.5) to draw a Doughnut chart. The sample shows proportion of seats taken by parties in UK elections.
Source code
#r "System.Windows.Forms.DataVisualization.dll" open System.Windows.Forms open System.Windows.Forms.DataVisualization.Charting let data = [ "Conservative", 306; "Labour", 258; "Liberal Democrat", 57 ] // Create a chart containing a default area and show it on a form let chart = new Chart(Dock = DockStyle.Fill) let form = new Form(Visible = true, Width = 700, Height = 500) chart.ChartAreas.Add(new ChartArea("MainArea")) form.Controls.Add(chart) // Create series and add it to the chart let series = new Series(ChartType = SeriesChartType.Doughnut) chart.Series.Add(series) // Specify data for the series using data-binding series.Points.DataBindXY(data, "Item1", data, "Item2")
Tags
charting
chart controls
charting
chart controls
Author
Link
Reference NuGet packages
If your snippet has external dependencies, enter the names of NuGet packages to reference, separated by a comma (
#r
directives are not required).
Update