如何在asp.net中绘制多个系列的折线图。 [英] How to draw line chart with multiple series in asp.net.

查看:121
本文介绍了如何在asp.net中绘制多个系列的折线图。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨专家,



我必须为3条记录创建折线图。这3条记录将以折线图中的3个独立系列显示。我必须每周显示一年的记录。



我尝试过:



以下是我试过的代码。



Deisgn

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

<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>





在Cod e后退。

我正在调用以下方法向图表提供数据。



In Code behind.
I am calling following method to provide data to the chart.

<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.

推荐答案

本文可能有所帮助,它描述了相同的主题,并且有一个与之关联的示例代码。



MSChart:如何绘制线条或多线图 [ ^ ]
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[^]


这篇关于如何在asp.net中绘制多个系列的折线图。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆