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

Radchart with Multipleserieses

1 Answer 73 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Satish
Top achievements
Rank 1
Satish asked on 11 Sep 2012, 08:21 PM
I would like bind a rad chart with multiple serieses with different datasets (dtDev,dtProd, dtQA), Could tell me how to the coding?  
  


Just take blind examples as we have three dates dtDev,dtProd, dtQA.


Please healp, Thank You in Advance!




    monthlyradchartcontrole.Clear()
    Dim dtDev as dataset = nothing
    dtDev = obj.datareturn(parameters)
    
    monthlyradchartcontrole.DataSource = dtDev
        
    monthlyradchartcontrole.DataBind()
        
    monthlyradchartcontrole.Series(0).DataXColumn = "ScheduledStartDate"
    monthlyradchartcontrole.Series(0).DataYColumn = "ChamberUtilization"
        
    monthlyradchartcontrole.PlotArea.XAxis.AxisLabel.TextBlock.Text = monthlyXaxislableName
    monthlyradchartcontrole.PlotArea.XAxis.AxisLabel.Visible = True
                    monthlyradchartcontrole.PlotArea.XAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.Red
    monthlyradchartcontrole.PlotArea.XAxis.AxisLabel.TextBlock.Appearance.Position.Auto = True
        
    monthlyradchartcontrole.PlotArea.YAxis.AxisLabel.Visible = True
    monthlyradchartcontrole.PlotArea.YAxis.AxisLabel.TextBlock.Text = monthlyYaxislableName
                    monthlyradchartcontrole.PlotArea.YAxis.AxisLabel.TextBlock.Appearance.TextProperties.Color = System.Drawing.Color.Red
    monthlyradchartcontrole.PlotArea.YAxis.AxisLabel.TextBlock.Appearance.Position.Auto = True
        
    monthlyradchartcontrole.Legend.Visible = False




Thank You,








1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 12 Sep 2012, 08:18 AM
Hello Satish,

Thanks for contacting us. 
 The following sample code snippet demonstrates how you can create a DataSet with two DataTables and bind the Chart to them so that you get two Line series as result:

protected void Page_Load(object sender, EventArgs e)
   {
       DataTable tbl = new DataTable();
       DataColumn col = new DataColumn("Value");
       col.DataType = typeof(double);
       tbl.Columns.Add(col);
       col = new DataColumn("XValue");
       col.DataType = typeof(double);
       tbl.Columns.Add(col);
   
       DataTable tbl1 = new DataTable();
       DataColumn col1 = new DataColumn("Value1");
       col1.DataType = typeof(double);
       tbl1.Columns.Add(col1);
       col1 = new DataColumn("XValue1");
       col1.DataType = typeof(double);
       tbl1.Columns.Add(col1);
   
       int size = 15;
       int maxLen = size.ToString().Length;
       for (int i = 1; i <= size; i++)
       {
           tbl.Rows.Add(new object[] { i * 2, i });
           tbl1.Rows.Add(new object[] { i * 3, i });
       }
   
       DataSet dsNew = new DataSet();
       dsNew.Tables.Add(tbl);
       dsNew.Tables.Add(tbl1);
   
       ChartSeries series1 = new ChartSeries("Series 1");
   
       series1.Type = ChartSeriesType.Line;
   
       foreach (DataRow dr in dsNew.Tables[0].Rows)
       {
   
           ChartSeriesItem item = new ChartSeriesItem();
   
           item.XValue = Convert.ToDouble(dr["XValue"].ToString());
   
           item.YValue = Convert.ToDouble(dr["Value"].ToString());
   
           series1.Items.Add(item);
   
       }
       RadChart1.Series.Add(series1);
   
       ChartSeries series2 = new ChartSeries("Series 2");
   
       series2.Type = ChartSeriesType.Line;
       foreach (DataRow dr in dsNew.Tables[1].Rows)
       {
   
           ChartSeriesItem item = new ChartSeriesItem();
   
           item.XValue = Convert.ToDouble(dr["XValue1"].ToString());
   
           item.YValue = Convert.ToDouble(dr["Value1"].ToString());
   
           series2.Items.Add(item);
   
       }
       RadChart1.Series.Add(series2);
   
       RadChart1.PlotArea.XAxis.DataLabelsColumn = "Day";
   }

Please note that there is no need to set the DataSet as DataSource for the RadChart since the Series Items are bound directly to the DataTables.

Greetings,
Evgenia
the Telerik team

If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Chart (Obsolete)
Asked by
Satish
Top achievements
Rank 1
Answers by
Evgenia
Telerik team
Share this question
or