Search code examples
c#asp.netcrystal-reports

How to display data into table and graph of crystal report


Actually, I am trying to display the data into a crystal report table and on graph. so please tell me if I have created one xyz.rpt file and create one table and graph structure inside this report. How to use these structures multiple times in my report. Suppose I have a student table and this table contains data of multiple class for example I have two classes data class 8 and class 9. In this situation all the data of the both class are displaying in a single table and single graph. but I am trying to display the class 8 data into a table after that my table terminates here and display graph for class 8 after that in second loop class 8 display in another table which comes after the first graph with the help of same table structure and then display the graph for this class.

Here is my code, Which display all data into single table and single graph..

  dtoverall = DbClass.getdata(CommandType.Text, "select vn.VelocityNormalX VNX,vn.VelocityNormalY VNY,vn.VelocityNormalZ VNZ,vn.Unit VNU, vn.SampleTimeVN VNT,an.AccelerationNormalX ANX,an.AccelerationNormalY ANY,an.AccelerationNormalZ ANZ,an.Unit ANU from vel_normal_overall vn left join acc_normal_overall an on vn.SampleTimeVN = an.SampleTimeAN where vn.SampleTimeVN between '" + SubTime + "' and '" + CurrTime + "' and vn.sensorid = '" + SensorNo + "'");
                            if (dtoverall.Rows.Count > 0)
                            {
                                foreach (DataRow drtime in dtoverall.Rows)
                                {
                                    convertedtime = timechange.IndianTime(Convert.ToString(drtime["VNT"]));
                                    string loc = FName + "/" + AName + "/" + TName + "/" + MName + "/" + PName;
                                    Overallall.Rows.Add(convertedtime, Convert.ToString(Math.Round(Convert.ToDouble(drtime["VNX"]),3))+Convert.ToString(drtime["VNU"]), Convert.ToString(Math.Round(Convert.ToDouble(drtime["VNY"]), 3)) + Convert.ToString(drtime["VNU"]), Convert.ToString(Math.Round(Convert.ToDouble(drtime["VNZ"]), 3)) + Convert.ToString(drtime["VNU"]), Convert.ToString(Math.Round(Convert.ToDouble(drtime["ANX"]), 3)) + Convert.ToString(drtime["ANU"]), Convert.ToString(Math.Round(Convert.ToDouble(drtime["ANX"]), 3)) + Convert.ToString(drtime["ANU"]), Convert.ToString(Math.Round(Convert.ToDouble(drtime["ANX"]), 3)) + Convert.ToString(drtime["ANU"]), loc);
                                }

}
crptall.Database.Tables["OverallForAll"].SetDataSource(Overallall);
                                CrysRptViewer.ReportSource = crptall;
                                CrysRptViewer.Refresh();
                        

Solution

  • Group the report by {Class}. You do this by using the menu option of Insert, Group... or by using Report, Group Expert...

    Then, place the chart in the Group Footer section.