예제 #1
0
        public ActionResult DoughnutUseTimeChart()
        {
            ViewBag.charttitle = Request.Query["title"];
            ViewBag.chartType  = Request.Query["chartType"];
            ViewBag.position   = Request.Query["position"];

            List <string>     label  = new List <string>();
            DevicesController device = new DevicesController();
            List <double>     data   = new List <double>();

            DevicesPowerUseOutputUtil powerUseOutputUtil = new DevicesPowerUseOutputUtil();

            double ACpower = Math.Round((powerUseOutputUtil.getACPowerUseTime() / 3600), 2);
            double LTpower = Math.Round((powerUseOutputUtil.getLPowerUseTime() / 3600), 2);
            double HDpower = Math.Round((powerUseOutputUtil.getHUMPowerUseTime() / 3600), 2);
            double EFpower = Math.Round((powerUseOutputUtil.getEXHFPowerUseTime() / 3600), 2);

            double[] myNum = { ACpower, LTpower, HDpower, EFpower };
            var      i     = 0;

            foreach (string getDeviceTypeName in device.typeName)
            {
                label.Add(getDeviceTypeName);
                //data.Add(device.GetDeviceCount(getDeviceTypeName));
                data.Add(myNum[i]);
                i++;
            }
            ViewBag.divId = GetRandomDivId();
            ChartController chart = new ChartController();

            ViewBag.datasets    = chart.DoughnutChart(label, data);
            ViewData["devices"] = label.ToJson();

            return(PartialView("_DoughnutChart"));
        }