示例#1
0
 public static PieChartObjectModel MapChartObjectToChartObjectModel(this PieChartObject chartObject)
 {
     if (chartObject == null)
     {
         return(null);
     }
     return(new PieChartObjectModel
     {
         Name = chartObject.Name,
         Y = chartObject.Y
     });
 }
        public ActionResult GetPieChartData()
        {
            ApplicationDbContext db       = new ApplicationDbContext();
            PieChartObject       billable = new PieChartObject();

            billable.color = "rgba(0, 168, 0, 0.6)";
            //billable.highlight = "rgba(0, 168, 0, 0.6)";
            billable.label = "Billable";
            IQueryable <WorkResponse> billables = from w in db.WorkResponses
                                                  where w.Billable
                                                  select w;

            foreach (WorkResponse wr in billables)
            {
                billable.value += Convert.ToInt32(wr.TimeWorked.TotalHours);
            }

            PieChartObject nonbillable = new PieChartObject();

            nonbillable.color = "rgba(255, 0, 0, 0.6)";
            //nonbillable.highlight = "rgba(255, 0, 0, 0.6)";
            nonbillable.label = "NonBillable";
            IQueryable <WorkResponse> nonbillables = from w in db.WorkResponses
                                                     where  !w.Billable
                                                     select w;

            foreach (WorkResponse wr in nonbillables)
            {
                nonbillable.value += Convert.ToInt32(wr.TimeWorked.TotalHours);
            }
            List <PieChartObject> pieChart = new List <PieChartObject>()
            {
                billable, nonbillable
            };
            JsonResult jr       = Json(pieChart.ToArray(), JsonRequestBehavior.AllowGet);
            string     jsondata = JsonConvert.SerializeObject(jr);

            return(jr);
        }
示例#3
0
 public void Export()
 {
     PieChartObject.Export();
 }
示例#4
0
        public string Create()
        {
            string reportPart = PieChartObject.Create();

            return(reportPart);
        }