For those who might want to use this, I have created a quick sample on how to use linq to create dynamic series for chartview:
Example is created in VS2010 / VB.NET
Make sure you import:
System.Data.DataSetExtensions.dll
to use linq.
Me
.RadChartView1.ShowLegend =
True
Me
.RadChartView1.ShowTitle =
True
Me
.RadChartView1.Title =
"Sold products per country"
Dim
graphSeries
As
New
DataTable()
graphSeries.Columns.Add(
"Category"
,
GetType
(
String
))
graphSeries.Columns.Add(
"Value"
,
GetType
(
Integer
))
graphSeries.Columns.Add(
"XValue"
,
GetType
(
String
))
graphSeries.Rows.Add(
"Netherlands"
, 10,
"2011"
)
graphSeries.Rows.Add(
"USA"
, 12,
"2011"
)
graphSeries.Rows.Add(
"Germany"
, 7,
"2011"
)
graphSeries.Rows.Add(
"Netherlands"
, 25,
"2012"
)
graphSeries.Rows.Add(
"USA"
, 40,
"2012"
)
graphSeries.Rows.Add(
"Germany"
, 25,
"2012"
)
Dim
productGroups = From p
In
graphSeries _
Group p By Category = p.Field(Of
String
)(
"Category"
) Into Group _
Select
Category, ProductGroup = Group
For
Each
g
In
productGroups
Dim
barSeries
As
New
Telerik.WinControls.UI.BarSeries(
"Value"
,
"Category"
)
barSeries.Name = g.Category
barSeries.ValueMember =
"Value"
barSeries.CategoryMember =
"XValue"
barSeries.ShowLabels =
True
barSeries.LegendTitle = g.Category
Me
.RadChartView1.Series.Add(barSeries)
barSeries.CombineMode = Telerik.Charting.ChartSeriesCombineMode.Stack
barSeries.DataSource = g.ProductGroup.CopyToDataTable
Next