How to implement Pie chart in application using MS Chart
I am going to implement a pie chart in my application using MS Chart. Before starting i would like to know whether is it possible to show more than 25 items in the chart and also is there any useful sites or codes that i can refer; other than mic开发者_开发知识库rosoft site (already referred).
Also suggest other chart implementation options. Thanks in advance for your responses :)
To create the chart from code, you'll need something like the code below. It is based on an F# sample from F# snippets web site (you can find examples of other charts there too). It can certainly display more than 25 elements, but the chart starts looking a bit ugly (because the labels don't fit quite well).
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
// Collection of elements with 'Label' and 'Value' properties
var data = (...)
// Create a chart containing a default area and show it on a form
var chart = new Chart { Dock = DockStyle.Fill };
var 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
var series = new Series { ChartType = SeriesChartType.Pie };
chart.Series.Add(series);
// Specify data for the series using data-binding
series.Points.DataBindXY(data, "Label", data, "Value");
Regarding other charting libraries for .NET, there are probably quite a few of them - Mono website has links to two of them (that look quite powerful) here.
精彩评论