This is a migrated thread and some comments may be shown as answers.

Databind from LINQ

1 Answer 221 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Henrique Duarte
Top achievements
Rank 1
Veteran
Henrique Duarte asked on 05 Jan 2008, 12:24 PM
Hi guys!

It's my first time using radChart.
I want to databing a line chart using a selecting event, but I don't know how to do it.

Here is my query:

var q = from f in dc.Faturas  
        where f.MesReferencia >= Convert.ToDateTime("01/01/2005")  
        && f.MesReferencia <= Convert.ToDateTime("01/05/2005")  
        group f by new 
        {  
            f.Conta.UnidadeGestora_link_Empresa.Empresa.TipoServico.NmTipoServico,  
            f.MesReferencia  
        } into g  
        orderby g.Key.NmTipoServico, g.Key.MesReferencia  
        select new 
        {  
            g.Key.NmTipoServico,  
            g.Key.MesReferencia,  
            Consumo = g.Sum(f => f.Consumo)  
        };  
 
e.Result = q;  
 

Here is the data returned from query:

 
NmTipoServico MesReferencia Consumo
Água e Esgoto 01/2005 87080
Água e Esgoto 02/2005 82731
Água e Esgoto 03/2005 94414
Água e Esgoto 04/2005 87396
Água e Esgoto 05/2005 87490
Eletricidade 01/2005 53439474
Eletricidade 02/2005 53415549
Eletricidade 03/2005 54183221
Eletricidade 04/2005 56598759
Eletricidade 05/2005 55553372
Gás 01/2005 23572
Gás 02/2005 22319
Gás 03/2005 19459
Gás 04/2005 26683
Gás 05/2005 32863
Telefonia 01/2005 2123603
Telefonia 02/2005 2111587
Telefonia 03/2005 2015812
Telefonia 04/2005 2071964
Telefonia 05/2005 2079275


Anyone can give me an example?

Thx!

Henrique

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 08 Jan 2008, 07:36 AM
Hello Henrique,

You can bind the chart using various techniques - please visit data-binding section in RadChart examples for more info. Here are few examples:

Binding to complex objects using ObjectDataSource:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Chart/Examples/DataBinding/Objects/DefaultCS.aspx

Binding to arrays:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Chart/Examples/DataBinding/Arrays/DefaultCS.aspx

Binding to lists:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Chart/Examples/DataBinding/Lists/DefaultCS.aspx

Please visit also this example to know more about how to declare line chart:
http://www.telerik.com/DEMOS/ASPNET/Prometheus/Chart/Examples/Skinning/Lines/DefaultCS.aspx

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Chart (Obsolete)
Asked by
Henrique Duarte
Top achievements
Rank 1
Veteran
Answers by
Vlad
Telerik team
Share this question
or