public virtual ActionResult HoursPerDayChartData() { var spentTimes = SpentTimeService.GetAll(Query.ForSpentTime() .Filter(x => x.ByAccepted(true).ByFromDate(DateTime.Now.AddMonths(-1)))) .Data .GroupBy(x => x.Date.Date).OrderBy(x => x.Key) .Select(x => new { date = x.Key, hours = (int)x.Aggregate(0m, (h, y) => h + y.Hours) }); var config = new MorrisConfig() { Data = spentTimes, XKey = "date", YKeys = new [] {"hours"}, Labels = new [] {"Hours"} }; var json = JsonConvert.SerializeObject(config); return Content(json, "application/json"); }
public virtual ActionResult TasksPerDayChartData() { var tasks = TaskService.GetAll(Query.ForTask() .Filter(x => x.ByDateCreatedFrom(DateTime.Now.AddMonths(-1)))) .Data .GroupBy(x => x.DateCreated.Date).OrderBy(x => x.Key) .Select(x => new { date = x.Key, tasks = x.Count() }); var config = new MorrisConfig() { Data = tasks, XKey = "date", YKeys = new[] { "tasks" }, Labels = new[] { "Tasks" } }; var json = JsonConvert.SerializeObject(config); return Content(json, "application/json"); }