Ejemplo n.º 1
0
        public IActionResult Districts()
        {
            var rnd   = new Random();
            var chart = new ChartDataModel <CharItem>()
            {
                Title         = "Districts",
                ChartDataList = new List <CharItem>
                {
                    new CharItem
                    {
                        Name  = "Жалал-Абад",
                        Value = rnd.Next(100, 10000)
                    },
                    new CharItem
                    {
                        Name  = "Бишкек",
                        Value = rnd.Next(100, 10000)
                    },
                    new CharItem
                    {
                        Name  = "Ош",
                        Value = rnd.Next(100, 10000)
                    },
                }
            };

            return(Ok(chart));
        }
Ejemplo n.º 2
0
        public ChartDataModule()
        {
            // would capture routes to /products/list sent as a GET request
            Get["/data/item/{name}/{id:int}"] = x =>
            {
                sql.Open(WebSettings.Settings.CreateDescription());

                string name = x.name;

                // Harcoded Limit of 40k data points for now
                // we will aggregate data soon, we should never have so much data hopefully
                string query = "(SELECT market.id,market.sellprice,market.buyprice,market.selloffers,market.buyorders,market.datetime FROM market where market.itemnumber = @id ORDER BY market.Datetime desc LIMIT 40000) ORDER BY id ASC;";
                var    p     = new Parameter {
                    Identifier = "@id", Value = x.id
                };
                var parmeter = new List <Parameter>();
                parmeter.Add(p);

                var            ds    = sql.SelectDataSet(query, parmeter);
                ChartDataModel model = new ChartDataModel();
                model.Name = name;
                if (ds != null && ds.Count > 0)
                {
                    foreach (var row in ds)
                    {
                        ChartItem item = ChartItem.CreateForChart(row);
                        model.Items.Add(item);
                    }
                }

                return(Response.AsJson(model));
            };
        }
Ejemplo n.º 3
0
        public ChartDataModel GetLineStateData(int?organId)
        {
            var            list   = new LineBusiness().GetAllItems();
            ChartDataModel result = new ChartDataModel(); //{ Titles = new List<string>(), Datas = new List<int>() };

            if (organId == null)                          //SysAdmin
            {
                var alarmcount  = list.FindAll(n => !n.ConnectState).Count;
                var normalcount = list.Count - alarmcount;
                result.Titles = new List <string> {
                    "报警线路", "正常线路"
                };
                result.Datas = new List <int> {
                    alarmcount, normalcount
                };
            }
            else
            {
                list = list.FindAll(n => n.OrganizationId == organId.Value);
                var alarmcount  = list.FindAll(n => !n.ConnectState).Count;
                var normalcount = list.Count - alarmcount;
                result.Titles = new List <string> {
                    "报警线路", "正常线路"
                };
                result.Datas = new List <int> {
                    alarmcount, normalcount
                };
            }
            return(result);
        }
Ejemplo n.º 4
0
        public JsonResult GetDataAfterSelectingTypeOfDegrees(string degrees)
        {
            if (degrees == "Fahrenheit")
            {
                return(this.GetChartData());
            }
            else
            {
                XDocument       chartDataDocument = XDocument.Load(Server.MapPath("~/App_Data/Charts/ChartEn.xml"));
                List <XElement> chartPoints       = chartDataDocument.Element("WeatherForecast").Elements().ToList();

                List <ChartDataModel> chartData = new List <ChartDataModel>();
                foreach (XElement element in chartPoints)
                {
                    ChartDataModel model = new ChartDataModel
                    {
                        Ax = element.Attribute("ax").Value,
                        Ay = (double.Parse(element.Attribute("ay").Value) - 32) * (5.0 / 9.0)
                    };

                    chartData.Add(model);
                }

                return(Json(chartData, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 5
0
        public ChartDataResponse GetChartData(ChartDataModel chartDataModel)
        {
            var dashboardObj = _Kernel.Get <ICompanyDashboard>();
            var result       = dashboardObj.GetChartData(chartDataModel);

            return(result);
        }
Ejemplo n.º 6
0
        private ChartDataModel GetData(ChartDataModel data)
        {
            var from   = data?.TimeInterval.From; //sets minimum
            var to     = data?.TimeInterval.To;   //sets maximum
            var result = new ChartDataModel();

            using (var db = new TemperatureContext())
            {
                var all = db.TemperatureData.ToList();
                result.Temps = all
                               .Where(temperatureData => temperatureData.Date >= from && temperatureData.Date <= to)
                               .OrderBy(temperatureData => temperatureData.Date)
                               .Select(temperatureData => new DataPointModel {
                    Date = temperatureData.Date, Y = temperatureData.Temperature
                })
                               .ToList();
                result.Hums = all
                              .Where(temperatureData => temperatureData.Date >= from && temperatureData.Date <= to)
                              .OrderBy(temperatureData => temperatureData.Date)
                              .Select(temperatureData => new DataPointModel {
                    Date = temperatureData.Date, Y = temperatureData.Humidity
                })
                              .ToList();
            }

            return(result);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 只有天数和分隔天数的时候,返回总告警
        /// </summary>
        /// <param name="Days"></param>
        /// <param name="partDay"></param>
        /// <returns></returns>
        public ChartDataModel GetAlarmCountData(int Days, int partDay, int?orgainId)
        {
            ChartDataModel chartAlarmMonth = new ChartDataModel()
            {
                Titles = new List <string>(), Datas = new List <int>()
            };
            Dictionary <DateTime, int> log = new Dictionary <DateTime, int>();

            if (orgainId == null)
            {
                log = new AlarmBusiness().GetLogDataForStatistics(DateTime.Now.AddDays((-1) * Days), DateTime.Now, null, partDay, Days);
            }
            else
            {
                int[] alarmIds = new AlarmBusiness().GetList(orgainId.Value).Select(n => n.Id).ToArray();
                log = new AlarmBusiness().GetLogDataForStatistics(DateTime.Now.AddDays((-1) * Days), DateTime.Now, alarmIds, partDay, Days);
            }

            foreach (var item in log)
            {
                chartAlarmMonth.Titles.Add(item.Key.ToString("yyyy-MM-dd"));
                chartAlarmMonth.Datas.Add(item.Value);
            }

            return(chartAlarmMonth);
        }
Ejemplo n.º 8
0
        public ChartDataModel GetOrganStateData(int?organId)
        {
            ChartDataModel result = new ChartDataModel(); //{ Titles = new List<string>(), Datas = new List<int>() };

            if (organId == null)                          //SysAdmin
            {
                var item        = new OrganDataProvider().GetPosition("", "");
                var alarmcount  = item.Where(n => n.State == 0).Count();
                var normalcount = item.Where(n => n.State == 1).Count();
                result.Titles = new List <string> {
                    "异常网点", "正常网点"
                };
                result.Datas = new List <int> {
                    alarmcount, normalcount
                };
            }
            else
            {
                var list = new OrganBusiness().GetChildren(organId.Value);

                var alarmcount  = list.FindAll(n => n.State != 1).Count;
                var normalcount = list.Count - alarmcount;
                result.Titles = new List <string> {
                    "异常网点", "正常网点"
                };
                result.Datas = new List <int> {
                    alarmcount, normalcount
                };
            }
            return(result);
        }
Ejemplo n.º 9
0
        public ChartDataModule()
        {
            // would capture routes to /products/list sent as a GET request
            Get["/data/item/{name}/{id:int}"] = x =>
            {
                sql.Open(WebSettings.Settings.CreateDescription());

                string name = x.name;

                string query = "SELECT market.id,market.sellprice,market.buyprice,market.selloffers,market.buyorders,market.datetime FROM market where market.itemnumber = @id;";
                var    p     = new Parameter {
                    Identifier = "@id", Value = x.id
                };
                var parmeter = new List <Parameter>();
                parmeter.Add(p);

                var            ds    = sql.SelectDataSet(query, parmeter);
                ChartDataModel model = new ChartDataModel();
                model.Name = name;
                if (ds != null && ds.Count > 0)
                {
                    foreach (var row in ds)
                    {
                        ChartItem item = ChartItem.CreateForChart(row);
                        model.Items.Add(item);
                    }
                }

                return(Response.AsJson(model));
            };
        }
Ejemplo n.º 10
0
        //TODO: return ModelClass with data for traffic
        public List <ChartDataModel> GetExpenditureData(string category)
        {
            var dataList = new List <ChartDataModel>();


            var categories = _categoryService.GetAll()
                             .FirstOrDefault(x => x.Title == category);


            if (category != null)
            {
                var expenditureData = _transactionService.GetAll()
                                      .Where(x => x.CategoryId == categories.Id).OrderBy(x => x.ExpenditureDate)
                                      .ToList();

                if (expenditureData != null)
                {
                    foreach (var item in expenditureData)
                    {
                        var dataModel = new ChartDataModel();
                        dataModel.Value           = item.Value;
                        dataModel.ExpenditureDate = item.ExpenditureDate;

                        dataList.Add(dataModel);
                    }


                    return(dataList);
                }
                return(dataList);
            }
            return(dataList);
        }
        public async Task <ChartDataModel> GetChartDataModel()
        {
            ChartDataModel chartData = null;

            try
            {
                using (var httpClient = InitializeHttpClient())
                {
                    var response = await httpClient.GetAsync(PatientChartUrl);

                    if (response.IsSuccessStatusCode)
                    {
                        var result = await response.Content.ReadAsStringAsync();

                        chartData = JsonConvert.DeserializeObject <ChartDataModel>(result);
                        if (chartData.PatientData == null)
                        {
                            chartData.PatientData = new PatientDataModel();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Warning("Error: ", ex.ToString());
            }
            return(chartData);
        }
Ejemplo n.º 12
0
        //public object GetIPPieData(int? switchId, string startIP, string endIP, string rangeName)
        //{
        //    object result = new
        //    {
        //        OccupySumData = GetOccupyData(switchId, startIP, endIP, rangeName, null),
        //        OnlineSumData = GetOnlineData(switchId, startIP, endIP, rangeName, null),
        //    };
        //    return result;
        //}

        /// <summary>
        /// 拼接告警折线图的数据
        /// </summary>
        /// <param name="switchId"></param>
        /// <param name="startIP"></param>
        /// <param name="endIP"></param>
        /// <param name="rangeName"></param>
        /// <returns></returns>
        //public object GetAlartLineData(int? switchId, string startIP, string endIP, string rangeName)
        //{
        //    int[] alarmsIds = GetAlarmIdInConfition(switchId, startIP, endIP, rangeName).ToArray();
        //    object result = new
        //    {
        //        AlartMonthData = GetAlarmCountData(30, 5, alarmsIds),
        //        AlartTwoMonthData = GetAlarmCountData(60, 10, alarmsIds),
        //        AlartSixMonthData = GetAlarmCountData(180, 30, alarmsIds)
        //    };
        //    return result;
        //}

        /// <summary>
        /// 拿告警数据条件里所需要的 AlarmIds
        /// </summary>
        /// <param name="switchId">交换机Id</param>
        /// <param name="startIP">起始IP</param>
        /// <param name="endIP">终止IP</param>
        /// <param name="rangeName">网段名称</param>
        /// <returns></returns>
        //private List<int> GetAlarmIdInConfition(int? switchId, string startIP, string endIP, string rangeName)
        //{
        //    List<int> alarmIds = new List<int>();
        //    List<AlarmModel> alarmList = new AlarmBusiness().GetList(switchId, rangeName, startIP, endIP).ToList();
        //    foreach (var item in alarmList)
        //    {
        //        alarmIds.Add(item.Id);
        //    }
        //    return alarmIds;
        //}


        /// <summary>
        /// 拿到告警图表要求的数据机构(折线图)
        /// </summary>
        /// <param name="Days">总天数</param>
        /// <param name="partDay">时间节点天数</param>
        /// <returns></returns>
        public ChartDataModel GetAlarmCountData(int Days, int partDay, int[] alarmIds)
        {
            ChartDataModel chartAlarmMonth = new ChartDataModel()
            {
                Titles = new List <string>(), Datas = new List <int>()
            };

            if (alarmIds.Length > 0)
            {
                Dictionary <DateTime, int> log = new AlarmBusiness().GetLogDataForStatistics(DateTime.Now.AddDays((-1) * Days), DateTime.Now, alarmIds, partDay, Days);
                foreach (var item in log)
                {
                    chartAlarmMonth.Titles.Add(item.Key.ToString("yyyy-MM-dd"));
                    chartAlarmMonth.Datas.Add(item.Value);
                }
            }
            else
            {
                for (int i = Days / partDay; i > 0; i--)
                {
                    chartAlarmMonth.Titles.Add(DateTime.Now.AddDays((-1) * i * partDay + partDay).ToString("yyyy-MM-dd"));
                    chartAlarmMonth.Datas.Add(0);
                }
            }
            return(chartAlarmMonth);
        }
Ejemplo n.º 13
0
        public ChartDataModel GetOrganlData(int?organId)
        {
            string         haslinesql = "select o.Id,o.`Name`,COUNT(o.Id) as 'Linecount' from tb_organization as o INNER  JOIN tb_line as l on o.Id=l.OrganizationId GROUP BY o.Id";
            string         nolinesql  = "SELECT o.`Name`,'0' as 'LineCount' from tb_organization as o where 1=1 ";//AND o.Id NOT IN @Id
            ChartDataModel result     = new ChartDataModel()
            {
                Titles = new List <string>(), Datas = new List <int>()
            };
            var haslinelist = new OrganBusiness().GetBySql(haslinesql, null);

            result.Titles = haslinelist.Select(n => n.Name).ToList();
            result.Datas  = haslinelist.Select(n => n.LineCount).ToList();
            var haslineIdArray = haslinelist.Select(n => n.Id).ToArray();
            var nolineList     = new OrganBusiness().GetBySql(haslineIdArray.Length > 0 ? $"{nolinesql} AND o.Id NOT IN @Id" : nolinesql, new { Id = haslineIdArray }).ToList();

            if (nolineList != null)
            {
                nolineList.ForEach(n =>
                {
                    result.Titles.Add(n.Name);
                    result.Datas.Add(n.LineCount);
                });
            }

            return(result);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Creates the user completed days charts.
        /// </summary>
        /// <returns></returns>
        public ChartModel CreateUserCompletedDaysChart()
        {
            using (var dbContext = GetDatabaseContext())
            {
                // Initial blank filter model.
                TaskFilterModel filterModel = new TaskFilterModel
                {
                    OriginalCreationDateFrom = DateTime.Now.AddDays(-14),
                    OriginalCreationDateTo   = DateTime.Now,
                    ActualFinishDateFrom     = DateTime.Now.AddDays(-14),
                    ActualFinishDateTo       = DateTime.Now,
                    StartedDate   = DateTime.Now.AddDays(-14),
                    AllUsers      = dbContext.Users.ToList(),
                    CreatedUserId = "",
                    TaskPriority  = -1
                };

                ChartModel chartModel = new ChartModel
                {
                    Type = "bar"
                };

                ChartDataModel chartDataModel = new ChartDataModel
                {
                    Labels = new List <string>()
                };

                int index = 0;
                foreach (User user in dbContext.Users.ToList())
                {
                    chartDataModel.Labels.Add(user.UserName);
                }

                ChartDatasetModel chartDatasetModel = new ChartDatasetModel
                {
                    Data            = new int[dbContext.Users.Count()],
                    BackgroundColor = new string[] { "#FF69B4" },
                    BorderColor     = new string[] { "#FFFFFF" },
                };

                IEnumerable <User> users = dbContext.Users.ToList();
                index = 0;
                foreach (User user in users.Where(user => user.AssignedTasks != null))
                {
                    int totalCompletedDays = user.AssignedTasks.Where(task => task.TaskStateId == 3 && task.ActualFinishDate >= filterModel.ActualFinishDateFrom &&
                                                                      task.ActualFinishDate <= filterModel.ActualFinishDateTo).Sum(task => task.ActualDaysTaken);
                    chartDatasetModel.Data[index] = totalCompletedDays;
                    index++;
                }

                chartDataModel.Datasets = new List <ChartDatasetModel> {
                    chartDatasetModel
                };
                chartModel.Data  = chartDataModel;
                chartModel.Title = "User Completed Days - Past Two Weeks";

                return(chartModel);
            }
        }
Ejemplo n.º 15
0
        private string getChartProcName(ChartDataModel chartDataModel)
        {
            string procName = string.Empty;

            if (chartProcNames.ContainsKey(chartDataModel.ChartId))
            {
                procName = chartProcNames[chartDataModel.ChartId];
            }
            return(procName);
        }
Ejemplo n.º 16
0
        private ChartItem GetCreateItem(ChartDataModel chartData, double maxValue)
        {
            ChartItem item = new ChartItem(this);

            item.TagName     = chartData.Tag;
            item.Value       = chartData.Value;
            item.MaxValue    = maxValue;
            item.ItemColor   = ItemColor;
            item.PopupText   = chartData.PopupText;
            item.IsSelected  = chartData.IsSelected;
            item.IsAnimation = IsAnimation;
            return(item);
        }
Ejemplo n.º 17
0
        /// <summary>
        /// <inheritdoc cref="IDataService.GetRunDataForChart"/>
        /// </summary>
        public ChartDataModel GetRunDataForChart(string runId)
        {
            string dir = DirectoryHelper.GetUserDocumentsFolder();

            if (IsComplete(dir, runId) == false)
            {
                return(default(ChartDataModel));
            }

            ChartDataModel model = ReadRunDataFromFiles(dir, runId);

            return(model);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Define what entites will be displayed on the chart
        /// </summary>
        protected void CreateCharts()
        {
            _instrument.ChartData.Area  = "Chart";
            _instrument.ChartData.Name  = _instrument.Name;
            _instrument.ChartData.Shape = nameof(ShapeEnum.Candle);

            _imbalanceIndicator.ChartData.Area  = "Volume";
            _imbalanceIndicator.ChartData.Name  = _imbalanceIndicator.Name;
            _imbalanceIndicator.ChartData.Shape = nameof(ShapeEnum.Bar);

            _performanceIndicator.ChartData.Area  = "Performance";
            _performanceIndicator.ChartData.Name  = _performanceIndicator.Name;
            _performanceIndicator.ChartData.Shape = nameof(ShapeEnum.Area);

            var deals = new ChartDataModel
            {
                Name  = "Transactions",
                Area  = _instrument.ChartData.Area,
                Shape = nameof(ShapeEnum.Arrow)
            };

            Charts = new IndexCollection <IChartModel>
            {
                new ChartModel
                {
                    Name      = _instrument.ChartData.Area,
                    ChartData = new NameCollection <string, IChartDataModel> {
                        _instrument.ChartData, deals
                    },
                    ShowValue = (i) =>
                    {
                        return(string.Format("{0:0.00}", i));
                    }
                },
                new ChartModel
                {
                    ValueCenter = 0,
                    Name        = _imbalanceIndicator.ChartData.Area,
                    ChartData   = new NameCollection <string, IChartDataModel> {
                        _imbalanceIndicator.ChartData
                    }
                },
                new ChartModel
                {
                    Name      = _performanceIndicator.ChartData.Area,
                    ChartData = new NameCollection <string, IChartDataModel> {
                        _performanceIndicator.ChartData
                    }
                }
            };
        }
Ejemplo n.º 19
0
        /// <summary>
        /// Reads the data to the chart from files
        /// </summary>
        /// <param name="dir"></param>
        /// <param name="runId"></param>
        /// <returns></returns>
        private ChartDataModel ReadRunDataFromFiles(string dir, string runId)
        {
            var runDir            = Path.Combine(dir, runId);
            var runDataFile       = Path.Combine(runDir, Settings.RunDataFileName);
            var resourceUsageFile = Path.Combine(runDir, $"{runId}.csv");

            var model = new ChartDataModel()
                        .ParseRunDataFile(runDataFile)
                        .ParseResourceUsage(resourceUsageFile)
                        .ReadHardwareSpecifics()
                        .CalculateUsageAverages();

            return(model);
        }
Ejemplo n.º 20
0
 public ChartDataResponse GetChartData(ChartDataModel chartDataModel)
 {
     try
     {
         return(this._dashboardDA.GetChartData(chartDataModel));
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         //Log
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Creates the estimated days bar chart.
        /// </summary>
        /// <returns></returns>
        public ChartModel CreateEstimatedDaysChart()
        {
            using (var dbContext = GetDatabaseContext())
            {
                ChartModel chartModel = new ChartModel
                {
                    Type = "bar"
                };

                ChartDataModel chartDataModel = new ChartDataModel
                {
                    Labels = new List <string>()
                };

                foreach (User user in dbContext.Users.ToList())
                {
                    chartDataModel.Labels.Add(user.UserName);
                }

                ChartDatasetModel chartDatasetModel = new ChartDatasetModel
                {
                    Data            = new int[dbContext.Users.Count()],
                    BackgroundColor = new string[] { "#FF69B4" },
                    BorderColor     = new string[] { "#FFFFFF" },
                    BorderWidth     = 1
                };

                int index = 0;

                foreach (User user in dbContext.Users.ToList())
                {
                    IEnumerable <Task> tasksWithinTimePeriod = user.AssignedTasks.Where(task => task.OriginalCreationDate >= DateTime.Now.AddDays(-14));

                    int totalEstimatedDays = tasksWithinTimePeriod != null?tasksWithinTimePeriod.Select(task => task.EstimatedDaysTaken).Sum() : 0;

                    chartDatasetModel.Data[index] = totalEstimatedDays;
                    index++;
                }

                chartDataModel.Datasets = new List <ChartDatasetModel> {
                    chartDatasetModel
                };
                chartModel.Data  = chartDataModel;
                chartModel.Title = "Estimated Days for each User - Active Tasks";
                return(chartModel);
            }
        }
Ejemplo n.º 22
0
        public HttpResponseMessage Get(int id)
        {
            try
            {
                ChartDataModel      res      = this._repo.TopOpenings(id);
                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, res);

                return(response);
            }
            catch (Exception ex)
            {
                _tracer.Error(Request, this.ControllerContext.ControllerDescriptor.ControllerType.FullName, ex.StackTrace);
                return(new HttpResponseMessage(HttpStatusCode.InternalServerError)
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// 渲染项目
        /// </summary>
        private void RenderItems()
        {
            if (Data == null)
            {
                return;
            }

            for (int i = 0; i < Data.Count(); i++)
            {
                ChartDataModel data = Data.ElementAt(i);
                ChartItem      item = GetCreateItem(data, MaxValue);
                if (i > 0)
                {
                    //添加间距
                    item.Margin = new Thickness(GapValue, 0, 0, 0);
                }
                ItemContainer.Children.Add(item);
            }
        }
Ejemplo n.º 24
0
        public JsonResult GetChartData()
        {
            XDocument       chartDataDocument = XDocument.Load(Server.MapPath("~/App_Data/Charts/ChartEn.xml"));
            List <XElement> chartPoints       = chartDataDocument.Element("WeatherForecast").Elements().ToList();

            List <ChartDataModel> chartData = new List <ChartDataModel>();

            foreach (XElement element in chartPoints)
            {
                ChartDataModel model = new ChartDataModel
                {
                    Ax = element.Attribute("ax").Value,
                    Ay = double.Parse(element.Attribute("ay").Value)
                };

                chartData.Add(model);
            }

            return(Json(chartData, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 25
0
        public ChartDataModel ResumeSources(int companyId)
        {
            List <Tuple <string, int> > objlist = this.DataContext.GetResumeSources(companyId);
            ChartDataModel model = new ChartDataModel();

            foreach (Tuple <string, int> obj in objlist)
            {
                model.Items.Add(new ChartData()
                {
                    x = obj.Item1,
                    y = new List <int>()
                    {
                        obj.Item2
                    },
                    tooltip = obj.Item1 + ": " + obj.Item2
                });
                model.Series.Add(obj.Item1);
            }

            return(model);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Prepares the chart with the RAM usage
        /// </summary>
        /// <param name="data"></param>
        /// <param name="axisXData"></param>
        private void PrepareRamChart(ChartDataModel data, double[] axisXData)
        {
            AvaPlot ramUsagePlot = this.Find <AvaPlot>("RamUsagePlot");

            // add series
            double[] ramAxisYData        = data.ResourceUsages.Select(u => Convert.ToDouble(SizeHelper.SizeValue(u.RamUsage, _displaySize))).ToArray();
            double[] maxRamAxisYData     = data.ResourceUsages.Select(u => Convert.ToDouble(SizeHelper.SizeValue(u.MaxRamAvailable, _displaySize))).ToArray();
            double[] ramPercentAxisYData = data.ResourceUsages.Select(u => Convert.ToDouble(u.RamPercentUsage)).ToArray();
            ramUsagePlot.Plot.AddScatter(axisXData, ramAxisYData, Color.Blue, 2F, label: "RAM usage");
            ramUsagePlot.Plot.AddScatter(axisXData, maxRamAxisYData, Color.Red, 2F, label: "Max RAM avaliable");
            // % ram series
            var ramScatter = ramUsagePlot.Plot.AddScatter(axisXData, ramPercentAxisYData, Color.Green, 2F, label: "% RAM usage");
            // secondary axis
            var secAxis = ramUsagePlot.Plot.AddAxis(Edge.Right, axisIndex: 2);

            secAxis.Label("% RAM usage");
            // set series to secondary axis
            ramScatter.YAxisIndex = 2;
            StylePlot(ramUsagePlot.Plot, ChartType.Ram);

            ramUsagePlot.Plot.Legend(true, Alignment.UpperLeft);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Creates the open tasks chart model.
        /// </summary>
        /// <returns></returns>
        public ChartModel CreateOpenTasksChart()
        {
            using (var dbContext = GetDatabaseContext())
            {
                ChartModel chartModel = new ChartModel
                {
                    Type = "polarArea"
                };

                ChartDataModel chartDataModel = new ChartDataModel
                {
                    Labels = new List <string> {
                        "Very Low", "Low", "Medium", "High", "Very High"
                    }
                };

                ChartDatasetModel chartDatasetModel = new ChartDatasetModel
                {
                    Data            = new int[5],
                    BackgroundColor = new string[] { "#4CE641", "#95EC32", "#F2F222", "#F88D11", "#FF1200" },
                    BorderColor     = new string[] { "#ffffff" },
                    BorderWidth     = 1
                };
                List <Task> openTasks = dbContext.Tasks.Where(task => task.TaskStateId == 1).ToList();

                chartDatasetModel.Data[0] = openTasks.Count(task => task.TaskPriority == 1);
                chartDatasetModel.Data[1] = openTasks.Count(task => task.TaskPriority == 2);
                chartDatasetModel.Data[2] = openTasks.Count(task => task.TaskPriority == 3);
                chartDatasetModel.Data[3] = openTasks.Count(task => task.TaskPriority == 4);
                chartDatasetModel.Data[4] = openTasks.Count(task => task.TaskPriority == 5);

                chartDataModel.Datasets = new List <ChartDatasetModel> {
                    chartDatasetModel
                };
                chartModel.Data  = chartDataModel;
                chartModel.Title = "Open Tasks - Priority Weighting";
                return(chartModel);
            }
        }
Ejemplo n.º 28
0
        public ChartDataModel GetAlarmData(int?organId)
        {
            var            list   = new AlarmBusiness().GetView();
            ChartDataModel result = new ChartDataModel(); //{ Titles = new List<string>(), Datas = new List<int>() };

            if (organId == null)                          //SysAdmin
            {
                var alarmcount  = list.Count();
                var normalcount = new LineBusiness().GetNormalLine(list.Select(n => n.LineId).ToArray()).Count();
                result.Titles = new List <string> {
                    "报警线路", "正常线路"
                };
                result.Datas = new List <int> {
                    alarmcount, normalcount
                };
            }
            else
            {
                //IEnumerable<AlarmModel> resultlist = list?.Where(n => n.OrganId == organId);
            }
            return(result);
        }
Ejemplo n.º 29
0
        private ChartDataModel CreateChartDataModelPerson(List <TimeDTO> times)
        {
            if (times.Any(t => t.FK_D != times[0].FK_D))
            {
                throw new InvalidDataException("Only times of one single discipline allowed!");
            }
            var dates  = CreateDates(times);
            var series = new List <DatasetModel> {
                CreateDatasetModel(times, dates)
            };
            var labels         = CreateLabels(dates);
            var options        = CreateChartOptions();
            var chartDataModel = new ChartDataModel
            {
                Datasets = series,
                Dates    = labels,
                Options  = options,
                Title    = times[0].Discipline.DisplayName
            };

            return(chartDataModel);
        }
Ejemplo n.º 30
0
        private async Task OnEmotionAnalysis()
        {
            resBosonEmotion = await BosonAIHelper.EmotionAnalysis(textInput.Text.Trim());

            if (resBosonEmotion != null)
            {
                if ((Application.Current as App).strCurrentLanguage.ToLower().Equals("zh-cn"))
                {
                    // Create a new chart data point for each value you want in the PieSeries
                    var sliceOne = new ChartDataModel {
                        Value = resBosonEmotion.positive, Title = "正面"
                    };
                    var sliceTwo = new ChartDataModel {
                        Value = resBosonEmotion.negtive, Title = "负面"
                    };

                    // Add those items to the list
                    chartItems.Add(sliceOne);
                    chartItems.Add(sliceTwo);
                }
                else
                {
                    // Create a new chart data point for each value you want in the PieSeries
                    var sliceOne = new ChartDataModel {
                        Value = resBosonEmotion.positive, Title = "Positive"
                    };
                    var sliceTwo = new ChartDataModel {
                        Value = resBosonEmotion.negtive, Title = "Negtive"
                    };

                    // Add those items to the list
                    chartItems.Add(sliceOne);
                    chartItems.Add(sliceTwo);
                }

                MyDoughnutSeries.ItemsSource = chartItems;
            }
        }
Ejemplo n.º 31
0
        public JsonResult GetDataAfterSelectingTypeOfDegrees(string degrees)
        {
            if (degrees == "Fahrenheit")
                return this.GetChartData();
            else
            {
                XDocument chartDataDocument = XDocument.Load(Server.MapPath("~/App_Data/Charts/ChartEn.xml"));
                List<XElement> chartPoints = chartDataDocument.Element("WeatherForecast").Elements().ToList();

                List<ChartDataModel> chartData = new List<ChartDataModel>();
                foreach (XElement element in chartPoints)
                {
                    ChartDataModel model = new ChartDataModel
                    {
                        Ax = element.Attribute("ax").Value,
                        Ay = (double.Parse(element.Attribute("ay").Value) - 32)*(5.0/9.0)
                    };

                    chartData.Add(model);
                }

                return Json(chartData, JsonRequestBehavior.AllowGet);
            }
        }
Ejemplo n.º 32
0
        public JsonResult GetChartData()
        {
            XDocument chartDataDocument = XDocument.Load(Server.MapPath("~/App_Data/Charts/ChartEn.xml"));
            List<XElement> chartPoints = chartDataDocument.Element("WeatherForecast").Elements().ToList();

            List<ChartDataModel> chartData = new List<ChartDataModel>();
            foreach (XElement element in chartPoints)
            {
                ChartDataModel model = new ChartDataModel
                {
                    Ax = element.Attribute("ax").Value,
                    Ay = double.Parse(element.Attribute("ay").Value)
                };

                chartData.Add(model);
            }

            return Json(chartData, JsonRequestBehavior.AllowGet);
        }