Exemplo n.º 1
0
        public ActionResult Graph()
        {
            var       context = new NewsdbEntities();
            ArrayList xValue  = new ArrayList();
            ArrayList yValue  = new ArrayList();

            //  var temp = (from m in db.Journalists where (m.Journalist_Id == temper) && (m.Id_System == userid) && (m.Id_System != null) select m.Journalist_Id).FirstOrDefault();
            //   var count = db.Suspenses.GroupBy(s => s.SuspenseDate.Month).Select(g => g.Count());


            KeyValuePair <string, int> list = new KeyValuePair <string, int>();
            var result = context.Articles.GroupBy(m => m.articleDate.Value.Year).Select(x => new
            {
                Date_Published = x.Key,
                Count          = x.Count()
            }).ToList();

            // var results = (from c in context.Articles.GroupBy(m => m.Date_Published.Year) select c.Count());
            result.ToList().ForEach(rs => xValue.Add(rs.Date_Published));
            result.ToList().ForEach(rs => yValue.Add(rs.Count));

            new Chart(width: 600, height: 400, theme: ChartTheme.Green)
            .AddTitle("Yearly Increase in Articles")
            .AddSeries("Default", chartType: "Column", xValue: xValue, yValues: yValue)
            .Write("bmp");
            return(null);
        }