Exemplo n.º 1
0
        public ActionResult IncomeByYear()
        {
            var income = Income.GetIncome();
            var result = from i in income
                         orderby i.Month
                         group i by i.Year into gb
                         select new
            {
                _year   = gb.Key.ToString(),
                _income = gb.Sum(n => n.Money)
            };
            var labels = result.Select(n => n._year);
            var money  = result.Select(n => n._income);

            return(Json(new { labels, money }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult IncomeByMonth()
        {
            var income = Income.GetIncome();
            var result = from i in income
                         orderby i.Month
                         group i by i.Month into sp

                         select new
            {
                month = sp.Key.ToString(),
                money = sp.Sum(n => n.Money)
            };
            var labels = result.Select(n => n.month);
            var money  = result.Select(n => n.money);

            return(Json(new { labels, money }, JsonRequestBehavior.AllowGet));
        }