Exemple #1
0
        public async Task <ActionResult> GetPieChart(string fromDatePie, string toDatePie)
        {
            string      accessToken        = Session["MicrosoftAccessToken"] as string;
            var         taskSubItemService = new TaskSubitemService(accessToken);
            UserService userService        = new UserService(accessToken);
            var         userId             = await userService.GetUserId(Session["UserId"] as string, UserDomainEnum.Microsoft);

            DateTime fromDate = DateTime.Parse(fromDatePie);
            DateTime toDate   = DateTime.Parse(toDatePie);
            var      taskSubitemsCompleted = await taskSubItemService.GetCompletedTaskSubitems(userId, fromDate, toDate);

            var taskSubitemsNotCompleted = await taskSubItemService.GetNotCompletedTaskSubitems(userId, fromDate, toDate);

            int    width      = 600;
            int    height     = 50;
            string chartTitle = "You don not have any tasks in this period of time";

            if (taskSubitemsCompleted.Any() || taskSubitemsNotCompleted.Any())
            {
                width      = 1024;
                height     = 700;
                chartTitle = "Your completed and not completed tasks";
            }

            var key = new Chart(width: width, height: height)
                      .AddSeries(
                chartType: "pie",
                legend: "Completed/NotCompleted",
                xValue:
                new[]
            {
                "Completed: " + taskSubitemsCompleted.Count,
                "Not completed: " + taskSubitemsNotCompleted.Count
            },
                yValues: new[] { taskSubitemsCompleted.Count, taskSubitemsNotCompleted.Count }).AddTitle(chartTitle)
                      .Write();

            return(null);
        }
Exemple #2
0
        public async Task <ActionResult> GetPieChart(string fromDatePie, string toDatePie)
        {
            string      accessToken        = Session["MicrosoftAccessToken"] as string;
            var         taskSubItemService = new TaskSubitemService(accessToken);
            UserService userService        = new UserService(accessToken);
            var         userId             = await userService.GetUserId(Session["UserId"] as string, UserDomainEnum.Microsoft);

            DateTime fromDate = DateTime.Parse(fromDatePie);
            DateTime toDate   = DateTime.Parse(toDatePie);
            var      taskSubitemsCompleted = await taskSubItemService.GetCompletedTaskSubitems(userId, fromDate, toDate);

            var taskSubitemsNotCompleted = await taskSubItemService.GetNotCompletedTaskSubitems(userId, fromDate, toDate);

            var key = new Chart(width: 1280, height: 720)
                      .AddSeries(
                chartType: "pie",
                legend: "Completed/NotCompleted",
                xValue: new[] { "Completed: " + taskSubitemsCompleted.Count, "Not completed: " + taskSubitemsNotCompleted.Count },
                yValues: new[] { taskSubitemsCompleted.Count, taskSubitemsNotCompleted.Count })
                      .Write();

            return(null);
        }