6 people like it.

Doughnut chart using chart controls

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.

 1: 
 2: 
 3: 
 4: 
 5: 
 6: 
 7: 
 8: 
 9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
#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")
namespace System
namespace System.Windows
val data : (string * int) list
val chart : obj
val form : obj
val series : obj

More information

Link:http://fssnip.net/3c
Posted:1 year ago
Author:Tomas Petricek
Tags: charting , chart controls