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

Radchart binding to List<>

1 Answer 17 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Ram
Top achievements
Rank 1
Ram asked on 03 Sep 2013, 12:27 PM
Hi All

I am trying to bind list below to a Radchart but it isn't binding correctly.

Can anyone please help?

Below code and Markup - attached JPG of what it looks like when I run it.

It should group by name, trnasmission and fuel - then display results for the year

I would like to see 4 series :-
BMW Auto Petrol
BMW Manual Petrol
BMW Auto Diesel
BMW Auto Petrol

Any help much appreciated.

Kind Regards,
Ram

if (!IsPostBack)
            {
                    var bm = new List<BMW>();
                    bm.Add(new BMW() { name = "BMW", value = 1, transmission = "auto", year = 2012, fuel = "Petrol" });
                    bm.Add(new BMW() { name = "BMW", value = 2, transmission = "auto", year = 2013, fuel = "Petrol" });
                    bm.Add(new BMW() { name = "BMW", value = 3, transmission = "manual", year = 2012, fuel = "Petrol" });
                    bm.Add(new BMW() { name = "BMW", value = 4, transmission = "manual", year = 2013, fuel = "Petrol" });
                    bm.Add(new BMW() { name = "BMW", value = 5, transmission = "auto", year = 2012, fuel = "Diesel" });
                    bm.Add(new BMW() { name = "BMW", value = 6, transmission = "auto", year = 2013, fuel = "Diesel" });
                    bm.Add(new BMW() { name = "BMW", value = 7, transmission = "manual", year = 2012, fuel = "Diesel" });
                    bm.Add(new BMW() { name = "BMW", value = 8, transmission = "manual", year = 2013, fuel = "Diesel" });
 
                    testing.PlotArea.XAxis.DataLabelsColumn = "year";
                    testing.DefaultType = Telerik.Charting.ChartSeriesType.Line;
 
                    //Use DataGroupColumn in order to group items
                    testing.DataGroupColumn = "name";
                    testing.DataManager.ValuesYColumns = new string[] { "transmission","fuel"};
 
                    testing.DataSource = bm;
                    testing.Height = 1200;
                    testing.Width = 1090;
                    testing.DataBind();
          }
}
 
 public class BMW
        {
            public string name { get; set; }
            public double value { get; set; }
            public string transmission { get; set; }
            public int year { get; set; }
            public string fuel { get; set; }
        }

<telerik:RadChart ID="testing" runat="server" Width="400px" SeriesOrientation="Vertical">
      <Series>
          <telerik:ChartSeries DataYColumn="value" Type="Line" Appearance-ShowLabels="true">
          </telerik:ChartSeries>
       </Series>
  </telerik:RadChart>

1 Answer, 1 is accepted

Sort by
0
Ram
Top achievements
Rank 1
answered on 04 Sep 2013, 02:11 PM
now fixed..
Tags
Chart (Obsolete)
Asked by
Ram
Top achievements
Rank 1
Answers by
Ram
Top achievements
Rank 1
Share this question
or