Home
Insert
Update snippet 'Bar 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 Bar chart. The sample shows population sizes in different continents.
Source code
#r "System.Windows.Forms.DataVisualization.dll" open System.Windows.Forms open System.Windows.Forms.DataVisualization.Charting // A collection of tuples containing titles and values for the chart let data = [ "Africa", 1033043; "Asia", 4166741; "Europe", 732759; "South America", 588649; "North America", 351659; "Oceania", 35838 ] // 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("MainAre")) form.Controls.Add(chart) // Create series and add it to the chart let series = new Series(ChartType = SeriesChartType.Bar) 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