Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Experts,

I have to create line chart for 3 records. These 3 records will be shown by 3 separate series in line chart. I have to display the records weekly for whole year.

What I have tried:

Following is the code I have tried.

In Deisgn
ASP.NET
<pre> <asp:Chart ID="Chart1" runat="server" Width="1059px">
                <Series>
                    <asp:Series Name="Series1" ChartType="Line" LegendText="Sap"></asp:Series>
                    </Series>

                     <Series>
                    <asp:Series Name="Series2" ChartType="Line" LegendText="Raildocs"></asp:Series>
                    </Series>

                     <Series>
                    <asp:Series Name="Series3" ChartType="Line" LegendText="RIC"></asp:Series>
                    </Series>
                <ChartAreas>
                    <asp:ChartArea Name="ChartArea1"></asp:ChartArea>
                </ChartAreas>
            </asp:Chart>


In Code behind.
I am calling following method to provide data to the chart.
C#
<pre> public void ProDocs()
        {
            using (ProDocsEntities objcontext = new ProDocsEntities())
            {
                DateTime startDate = new DateTime(DateTime.Today.Year, 1, 1);
                for (int i = 1; i <= 53; i++)
                {
                    //DateTime startDate = new DateTime();
                   // DateTime endDate = new DateTime();
                      
                      DateTime endDate = startDate.AddDays(7 - (int)(startDate.DayOfWeek));
                      
                    

                    var SapData = (from a in objcontext.FileProgresses
                                   join pg in objcontext.V01_PG on a.ProDocsId equals (int?)pg.ID into pgs
                                   from g in pgs.DefaultIfEmpty()
                                   join pr in objcontext.V01_PR on g.ID equals pr.PAGE into prs
                                   from p in prs.DefaultIfEmpty()
                                   where a.FullPath.Contains("2014KR0055") && (a.Received >= startDate && a.Received <= endDate) && (a.AvailableInProDocs != null)
                                   select new { a.Id, a.Downloaded, a.Unsupported, a.ProcessByAbbyy, a.AvailableInProDocs, a.AvailableInDocs2Go, a.LocDocMapping }).ToList();
                    int SapCount = SapData.Count();
                    var RaildocsData = (from a in objcontext.FileProgresses
                                        join pg in objcontext.V01_PG on a.ProDocsId equals (int?)pg.ID into pgs
                                        from g in pgs.DefaultIfEmpty()
                                        join pr in objcontext.V01_PR on g.ID equals pr.PAGE into prs
                                        from p in prs.DefaultIfEmpty()
                                        where a.FullPath.Contains("2014KR0062") && (a.Received >= startDate && a.Received <= endDate) && (a.AvailableInProDocs != null)
                                        select new { a.Id, a.Downloaded, a.Unsupported, a.ProcessByAbbyy, a.AvailableInProDocs, a.AvailableInDocs2Go, a.LocDocMapping }).ToList();
                    int raildocCount = RaildocsData.Count();
                    var RicData = (from a in objcontext.FileProgresses
                                   join pg in objcontext.V01_PG on a.ProDocsId equals (int?)pg.ID into pgs
                                   from g in pgs.DefaultIfEmpty()
                                   join pr in objcontext.V01_PR on g.ID equals pr.PAGE into prs
                                   from p in prs.DefaultIfEmpty()
                                   where a.FullPath.Contains("2015KR0050") && (a.Received >= startDate && a.Received <= endDate) && (a.AvailableInProDocs != null)
                                   select new { a.Id, a.Downloaded, a.Unsupported, a.ProcessByAbbyy, a.AvailableInProDocs, a.AvailableInDocs2Go, a.LocDocMapping }).ToList();
                    int RicCount = RicData.Count();

                    Series series1 = Chart1.Series["Series1"];
                    series1.Points.AddY( SapCount);
                    series1.Points.AddY( raildocCount);
                    series1.Points.AddY( RicCount);
                    Series series2 = Chart1.Series["Series2"];
                    series2.Points.AddY(SapCount);
                    series2.Points.AddY(raildocCount);
                    series2.Points.AddY(RicCount);
                    Series series3 = Chart1.Series["Series3"];
                    series3.Points.AddY(SapCount);
                    series3.Points.AddY(raildocCount);
                    series3.Points.AddY(RicCount);
                    
                    

                    startDate = endDate;

                }
            }
        }


Any Help will be appreciated.
Thanks In Advance.
Posted
Updated 10-Mar-17 2:58am

1 solution

This article might help, it describe the same topic and there is a sample code associated with it.

MSChart : How to Draw a Line or Multiple Line Charts[^]
 
Share this answer
 

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