Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to generate a .net ActiveReport chart with 3 different series
Series1 type = line, series2 type = line and series3 type = bar. Datatable has been used to pull data from database and then each column data is converted into list collection so as to use DataBindXY() method. Problem, I am facing are :
1) Each series uses its own x-axis labels they are not sharing the x-axis label range, so there are duplicate data in x-axis label.
2) Series2 (Bar 2D) is not started with proper x axis data i,e my data for bar chart is (2004,-25), (2030,-65). Rather it starts from (1000,-25) and (2004,-65)

I also tried plotting series by passing static values in Databindxy method, code is commented below.

I am new to activereports and I am facing lots of problems
----------------------------------------------------------------

What I have tried:

C#
private void reportHeader1_Format(object sender, EventArgs e)
       {

           if (dbConnection == null || inspectionID < 1)
           {
               return;
           }
           GrapeCity.ActiveReports.Chart.Series series1 = new GrapeCity.ActiveReports.Chart.Series();
           series1.Type = GrapeCity.ActiveReports.Chart.ChartType.Bar2D;

           DataSet tds = GetDetail(inspectionID);
           if (tds != null)
           {
               if (tds.Tables[0].Rows.Count > 0)
               {
                   DataRow tdr = tds.Tables[0].Rows[0];
                   if (tdr != null)
                   {
                       /// Series 3 - series type is Bar 2D

                       List<double> bentSounding = new List<double>();
                       List<double> bentDistance = new List<double>();

                       for (int index = 0; index < tds.Tables[0].Rows.Count; index++)
                       {
                           string bentValue = tds.Tables[0].Rows[index]["Bent"].ToString();
                           if (bentValue != "")
                           {
                               bentSounding.Add(0);
                               bentDistance.Add(Double.Parse(tds.Tables[0].Rows[index]["station"].ToString()));
                               
                           }
                       }

                       // series 1 - type is line

                       Double MinWSDist = 0D, MaxWSDist = 0D, MinWSSounding = 0D, MaxWSSounding = 0D;
                       int MinIndex = 0;
                       int MaxIndex = 0;

                       List<double> wsSounding = new List<double>();
                       List<double> wsDistance = new List<double>();


                       for (int index = 0; index < tds.Tables[0].Rows.Count; index++)
                       {
                           string waterSurfaceValue = tds.Tables[0].Rows[index]["Water_Surface"].ToString();
                           if (waterSurfaceValue != "")
                           {
                               wsSounding.Add(Double.Parse(tds.Tables[0].Rows[index]["downstream"].ToString())*-1);
                               wsDistance.Add(Double.Parse(tds.Tables[0].Rows[index]["station"].ToString()));                              

                           }
                       }

                       // get max and min value in watersurface
                       MaxWSDist = wsDistance.Max();
                       MaxIndex = wsDistance.FindIndex(s => s == MaxWSDist);
                       MinWSDist = wsDistance.Min();
                       MinIndex = wsDistance.FindIndex(s => s == MinWSDist);

                       MaxWSSounding = wsSounding.ElementAt(MaxIndex);
                       MinWSSounding = wsSounding.ElementAt(MinIndex);

                      //series 0 type is line

                       List<double> sounding = new List<double>();
                       List<double> distance = new List<double>();
                     
                       for (int index = 0; index < tds.Tables[0].Rows.Count; index++)
                       {
                           sounding.Add(Double.Parse(tds.Tables[0].Rows[index]["downstream"].ToString()) * -1);
                       }


                       for (int index = 0; index < tds.Tables[0].Rows.Count; index++)
                       {
                           distance.Add(Double.Parse(tds.Tables[0].Rows[index]["station"].ToString()));
                       }

                      

                       this.chartControl1.Series[0].Points.DataBindXY(distance, sounding);
                       this.chartControl1.Series[1].Points.DataBindXY(new[] { MinWSDist, MaxWSDist }, new[] { MinWSSounding, MaxWSSounding });
                       this.chartControl1.Series[2].Points.DataBindXY(bentDistance, bentSounding);


                     // this.chartControl1.Series[0].Points.DataBindXY(new[] { 1000, 2001, 2005, 2006, 2008, 2010 }, new[] { -35, -05, -35, -38, -20, -10 });
                      //  this.chartControl1.Series[1].Points.DataBindXY(new[] { 1000, 2030 }, new[] { -25, -65 });
                       // this.chartControl1.Series[2].Points.DataBindXY(new[] { 2000, 2002, 2004 }, new[] { 0, 0, 0 });
                     

                      

                   }
               }
               tds.Dispose();
           }
       }
Posted
Updated 27-Jun-16 4:21am
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900