Adding Data Values to a Pie Chart
The following code adds data values to a Pie chart:
Dim names As String() = New String() {"Apples", "Oranges", "Peaches"}
Dim values As Double() = New Double() {20R, 10R, 7R}
Dim ds As New DataSeries()
chart.Data.Children.Add(ds)
chart.Data.ItemNames = names
chart.ChartType = ChartType.Pie
•C#
string[] names = new string[] { "Apples", "Oranges", "Peaches"};
double[] values = new double[] { 20.0, 10.0, 7.0 };
DataSeries ds = new DataSeries() { ValuesSource = values};
chart.Data.Children.Add(ds);
chart.Data.ItemNames = names;
chart.ChartType = ChartType.Pie;