Does Teechart support datasource as Generic List<T>?
Posted: Wed Mar 11, 2009 8:26 am
I use LinQ2SQL to access database in my project, and most of query results is IQueryable<> or List<>. But it seems Teechart cannot work with such datasource. I don't want to convert my List<> source to DataTable, that takes a horribly long time. Another way, writing an ADO link to get DataTable specially for Teechart is also very fool, I already have my own data-access methods.
Can't I set an IList as datasource and specify a property of the elementtype as labelmember and another as datamember? It's very easy for all official .NET controls which uses datasource. For example:
All of above can work, but when I try to do it to a WebChart:
even cannot pass the compilation.
System.Collections.IList and System.Collections.Generic.List<T> are common datasources, but TeeChart doesn't support them?
So I would like to know what I'm supposed to do if I need the chart shows properly.
Thank you!
Can't I set an IList as datasource and specify a property of the elementtype as labelmember and another as datamember? It's very easy for all official .NET controls which uses datasource. For example:
Code: Select all
public class Person
{
public string Name {get;set;}
public int Age {get;set;}
}
List<Person> crowd = new List<Person>
{
new Person { Name = "Tom", Age = 20 },
new Person { Name = "Jack", Age = 27 },
new Person { Name = "Andy", Age = 22 }
};
DropDownList1.DataSource = crowd;
DropDownList1.DataTextField = "Name";
DropDownList1.DataValueField = "Age";
DropDownList1.DataBind();
DataList1.DataSource = crowd;
DataList1.DataBind();
GridView1.DataSource = crowd;
GridView1.DataBind();
.....
Code: Select all
Steema.TeeChart.Styles.Pie pie1 = new Steema.TeeChart.Styles.Pie(WebChart1.Chart);
pie1.DataSource = crowd;
pie1.LabelMember = "Name";
pie1.YValues.DataMember = "Age";
System.Collections.IList and System.Collections.Generic.List<T> are common datasources, but TeeChart doesn't support them?
So I would like to know what I'm supposed to do if I need the chart shows properly.
Thank you!