Converting DataSet to DataSeries
You can convert the DataSet to DataSeries using just one DataSeries like the following:
•XAML
C1Chart1.Theme = ChartTheme.Office2003Classic
Dim dt As New DataTable()
dt.Columns.Add("Name", GetType(String))
dt.Columns.Add("Value", GetType(Double))
dt.Rows.Add("Apples", 20R)
dt.Rows.Add("Oranges", 10R)
dt.Rows.Add("Peaches", 7R)
chart.Data.ItemNameBinding = New Binding("Name")
chart.Data.Children.Add(New DataSeries())
chart.Data.ItemsSource = dt.DefaultView
chart.ChartType = ChartType.Pie
•C#
DataTable dt = new DataTable();
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Value", typeof(double));
dt.Rows.Add("Apples", 20.0);
dt.Rows.Add("Oranges", 10.0);
dt.Rows.Add("Peaches", 7.0);
chart.Data.ItemNameBinding = new Binding("Name");
chart.Data.Children.Add(new DataSeries() { ValueBinding = new Binding("Value") });
chart.Data.ItemsSource = dt.DefaultView;
chart.ChartType = ChartType.Pie;