I've tried to put several charts on the report and bind programmatically them. So, the first chart at the header of report binds fine, but other in report body binds to first chart.
private void chart1_NeedDataSource(object sender, System.EventArgs e)
{
Telerik.Reporting.Processing.Chart chart = (Telerik.Reporting.Processing.Chart)sender;
try
{
string sql = "select COUNT(*) as Marks_Count, MARK_NAME, Custom_Name from v_marks GROUP BY MARK_NAME, Custom_Name";
SqlCommand sqlComm = new SqlCommand(sql, new SqlConnection(ConfigurationManager.ConnectionStrings["reportConnectionString"].ConnectionString));
SqlDataAdapter da = new SqlDataAdapter(sqlComm);
DataTable dt = new DataTable();
da.Fill(dt);
chart1.Series[0].DataLabelsColumn = "Mark_Name";
chart.DataSource = dt;
}
catch (System.Exception ex)
{ System.Diagnostics.Debug.WriteLine( ex.Message); }
}
private void chart2_NeedDataSource(object sender, System.EventArgs e)
{
Telerik.Reporting.Processing.Chart chart = (Telerik.Reporting.Processing.Chart)sender;
try
{
string sCustomName = ((DataRowView)chart.DataItem)["Custom_Name"] as string;
if (!string.IsNullOrEmpty(sCustomName))
{
string sql = string.Format("select COUNT(*) as Marks_Count, MARK_NAME from v_marks WHERE Custom_Name='{0}' GROUP BY MARK_NAME", sCustomName);
SqlCommand sqlComm = new SqlCommand(sql, new SqlConnection(ConfigurationManager.ConnectionStrings["reportConnectionString"].ConnectionString));
SqlDataAdapter da = new SqlDataAdapter(sqlComm);
DataTable dt = new DataTable();
da.Fill(dt);
chart2.Series[0].DataLabelsColumn = "Mark_Name";
chart.DataSource = dt;
}
}
catch (System.Exception ex)
{System.Diagnostics.Debug.WriteLine(ex.Message);}
}
----------- The part of Desing file ---------------
//
// reportHeader
//
this.reportHeader.Height = new Telerik.Reporting.Drawing.Unit(12.459259986877441, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm)));
this.reportHeader.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.titleTextBox,
this.chart1});
this.reportHeader.Name = "reportHeader";
//
// detail
//
this.detail.Height = new Telerik.Reporting.Drawing.Unit(8.0877304077148438, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm)));
this.detail.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.textBox1,
this.textBox2,
this.chart2});
this.detail.Name = "detail";
//
// chart1
//
this.chart1.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.chart1.BitmapResolution = 96F;
this.chart1.DefaultType = Telerik.Reporting.Charting.ChartSeriesType.Pie;
this.chart1.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf;
this.chart1.Legend.Appearance.Visible = false;
this.chart1.Legend.Visible = false;
this.chart1.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(0.37037038803100586, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))), new Telerik.Reporting.Drawing.Unit(1.3857144117355347, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))));
this.chart1.Name = "chart1";
this.chart1.PlotArea.DataTable.Appearance.CellWidth = 25;
this.chart1.PlotArea.XAxis.MinValue = 1;
chartSeries1.DataXColumn = "Mark_Name";
chartSeries1.DataYColumn = "Marks_Count";
chartSeries1.Name = "Series 1";
chartSeries1.Type = Telerik.Reporting.Charting.ChartSeriesType.Pie;
this.chart1.Series.AddRange(new Telerik.Reporting.Charting.ChartSeries[] {
chartSeries1});
this.chart1.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(15.391534805297852, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))), new Telerik.Reporting.Drawing.Unit(10.873545646667481, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))));
this.chart1.NeedDataSource += new System.EventHandler(this.chart1_NeedDataSource);
//
// chart2
//
this.chart2.BitmapResolution = 96F;
this.chart2.DefaultType = Telerik.Reporting.Charting.ChartSeriesType.Pie;
this.chart2.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf;
this.chart2.Legend.Appearance.Visible = false;
this.chart2.Legend.Visible = false;
this.chart2.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(0.37037038803100586, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))), new Telerik.Reporting.Drawing.Unit(0.74084246158599854, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))));
this.chart2.Name = "chart2";
this.chart2.PlotArea.XAxis.MinValue = 1;
chartSeries2.Name = "Series 1";
chartSeries2.Type = Telerik.Reporting.Charting.ChartSeriesType.Pie;
this.chart2.Series.AddRange(new Telerik.Reporting.Charting.ChartSeries[] {
chartSeries2});
this.chart2.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(15.391533851623535, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))), new Telerik.Reporting.Drawing.Unit(7.3203325271606445, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))));
this.chart2.NeedDataSource += new System.EventHandler(this.chart2_NeedDataSource);
//
// reportHeader
//
this.reportHeader.Height = new Telerik.Reporting.Drawing.Unit(12.459259986877441, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm)));
this.reportHeader.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.titleTextBox,
this.chart1});
this.reportHeader.Name = "reportHeader";
//
// detail
//
this.detail.Height = new Telerik.Reporting.Drawing.Unit(8.0877304077148438, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm)));
this.detail.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.textBox1,
this.textBox2,
this.chart2});
this.detail.Name = "detail";
//
// chart1
//
this.chart1.Anchor = System.Windows.Forms.AnchorStyles.Top;
this.chart1.BitmapResolution = 96F;
this.chart1.DefaultType = Telerik.Reporting.Charting.ChartSeriesType.Pie;
this.chart1.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf;
this.chart1.Legend.Appearance.Visible = false;
this.chart1.Legend.Visible = false;
this.chart1.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(0.37037038803100586, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))), new Telerik.Reporting.Drawing.Unit(1.3857144117355347, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))));
this.chart1.Name = "chart1";
this.chart1.PlotArea.DataTable.Appearance.CellWidth = 25;
this.chart1.PlotArea.XAxis.MinValue = 1;
chartSeries1.DataXColumn = "Mark_Name";
chartSeries1.DataYColumn = "Marks_Count";
chartSeries1.Name = "Series 1";
chartSeries1.Type = Telerik.Reporting.Charting.ChartSeriesType.Pie;
this.chart1.Series.AddRange(new Telerik.Reporting.Charting.ChartSeries[] {
chartSeries1});
this.chart1.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(15.391534805297852, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))), new Telerik.Reporting.Drawing.Unit(10.873545646667481, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))));
this.chart1.NeedDataSource += new System.EventHandler(this.chart1_NeedDataSource);
//
// chart2
//
this.chart2.BitmapResolution = 96F;
this.chart2.DefaultType = Telerik.Reporting.Charting.ChartSeriesType.Pie;
this.chart2.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf;
this.chart2.Legend.Appearance.Visible = false;
this.chart2.Legend.Visible = false;
this.chart2.Location = new Telerik.Reporting.Drawing.PointU(new Telerik.Reporting.Drawing.Unit(0.37037038803100586, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))), new Telerik.Reporting.Drawing.Unit(0.74084246158599854, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))));
this.chart2.Name = "chart2";
this.chart2.PlotArea.XAxis.MinValue = 1;
chartSeries2.Name = "Series 1";
chartSeries2.Type = Telerik.Reporting.Charting.ChartSeriesType.Pie;
this.chart2.Series.AddRange(new Telerik.Reporting.Charting.ChartSeries[] {
chartSeries2});
this.chart2.Size = new Telerik.Reporting.Drawing.SizeU(new Telerik.Reporting.Drawing.Unit(15.391533851623535, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))), new Telerik.Reporting.Drawing.Unit(7.3203325271606445, ((Telerik.Reporting.Drawing.UnitType)(Telerik.Reporting.Drawing.UnitType.Cm))));
this.chart2.NeedDataSource += new System.EventHandler(this.chart2_NeedDataSource);