public MainPage() { var themeLoader = new ThemeLoader(); themeLoader.LoadTheme(); InitializeComponent(); repository = new Repository(); period = new Period(); pageService = new PageService(); initializeDatabase = new InitializeDatabase(pageService); period.Init(DateTime.Now, PeriodType.Month); trans = repository.GetTransactions(period); navigationBarViewModel = new NavigationBarViewModel(trans, pageService, repository, period); charts = new ChartsViewModel(navigationBarViewModel, pageService, repository); transactionsViewModel = new TransactionsViewModel(navigationBarViewModel, pageService, repository, period); MainVM = new MainPageViewModel(pageService, repository, initializeDatabase); this.BindingContext = MainVM; overview.BindingContext = charts; transactions.BindingContext = transactionsViewModel; MessagingCenter.Subscribe <NavigationBarViewModel>(this, MessagingString.UpdatePeriod, RefreshTransactions); MessagingCenter.Subscribe <SettingsPage>(this, MessagingString.UpdateTransactionsAfterSettingsChange, RefreshTransactions); MessagingCenter.Subscribe <SettingsViewModel>(this, MessagingString.UpdateTransactionsAfterReset, RefreshTransactions); MessagingCenter.Subscribe <TransactionsDetailsViewModel>(this, MessagingString.UpdateTransactions, RefreshTransactions); MessagingCenter.Subscribe <TransactionsViewModel>(this, MessagingString.DeleteTransactions, RefreshTransactions); MessagingCenter.Subscribe <TransactionsViewModel>(this, MessagingString.RefreshTransactions, RefreshTransactions); }
/// <summary> /// The Constructor set the DataContext of the Window to an object of the ViewModel class. /// </summary> public MainWindow() { InitializeComponent(); var vm = new ChartsViewModel(); DataContext = vm; }
public JsonResult CampaignDashBoardList(string campaign) // accepts campaign of the country and passes the list of data by JSON call { List <string> data = new List <string>(); // asigned the returned list to this and pass it to json parameter ChartsViewModel cVM = new ChartsViewModel(); String uId = User.Identity.GetUserId(); // get logged in users Id RegisterViewModel userDetails = cVM.GetUserDetailsById(uId); // get signed in users details var country = userDetails.Country; try { // here you need to get the data to display it in the chart var response = cVM.GetAllTheDeTailsRelatedToEachCountry(country, campaign); if (!object.Equals(response, null)) { data = response; } } catch (Exception ex) { throw; } return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult ChartData() { StatsService service = new StatsService(); ChartsViewModel chartVM = service.GetChartsData(); return(Json(chartVM, JsonRequestBehavior.AllowGet)); }
private void SetLengthCsvPoints(ChartsViewModel model, int?maxAge) { var maxAgeInMonthsCeiling = maxAge ?? (int)Math.Ceiling(model.LengthPoints.Max(p => p.X)) + 1; var data = _lengthForAgeData.Take(maxAgeInMonthsCeiling); model.LengthPointsSD0 = JsonSerializer.Serialize(data.Select(row => new Point(row.Month, row.SD0)).ToList()); model.LengthPointsSD2 = JsonSerializer.Serialize(data.Select(row => new Point(row.Month, row.SD2)).ToList()); model.LengthPointsSD2neg = JsonSerializer.Serialize(data.Select(row => new Point(row.Month, row.SD2neg)).ToList()); }
public async Task <IActionResult> Charts() { _logger.LogInformation($"{nameof(HomeController.Charts)} called."); var tempChartData = new ChartData <double> { Datasets = new List <ChartDataset <double> > { new ChartDataset <double> { Label = "Temperature", YaxisID = "y-axis-1", BorderColor = "rgb(255, 99, 132)", BackgroundColor = "rgb(255, 99, 132)" } } }; var humiChartData = new ChartData <double> { Datasets = new List <ChartDataset <double> > { new ChartDataset <double> { Label = "Humidity", YaxisID = "y-axis-2", BorderColor = "rgb(54, 162, 235)", BackgroundColor = "rgb(54, 162, 235)" } } }; // sensor chart data var tempDbData = await _temperatureService .GetByTimeIntervalGroupedByHour(DateTime.UtcNow.AddHours(-24)) .ToListAsync(); var labels = new List <string>(); foreach (var temp in tempDbData) { labels.Add(temp.DateTime.ToString(TimeFormat)); tempChartData.Datasets[0].Data.Add(Math.Round(temp.Temperature, 1)); humiChartData.Datasets[0].Data.Add(Math.Round(temp.Humidity, 1)); } tempChartData.Labels = labels; humiChartData.Labels = labels; var chartViewData = new ChartsViewModel { TemperatureChartData = tempChartData, HumidityChartData = humiChartData }; return(View(chartViewData)); }
async Task ExecuteRunHeuristic() { try { List <Problem> problems = null; IHeuristicConfigurationSetting settings = null; if (Context.Instance.Settings.GeneralSettings.MultiplesExecutions) { problems = Context.Instance.Problems; } else { problems = new List <Problem> { Context.Instance.Problems.Where(t => t.ID_Problem.Equals(DARPSelected)).ToList().First() } }; switch (Context.Instance.Settings.GeneralSettings.DefaultHeuristic) { case "ILS": settings = Context.Instance.Settings.ILSConfigurationSettings; break; default: settings = Context.Instance.Settings.ILSConfigurationSettings; break; } //Mostrar Splash splashController.ShowSplash(new SplashInfo()); RunMetaheuristicInput input = new RunMetaheuristicInput { Problems = problems, HeuristicSettings = settings, Random = new Random(1) }; RunMetaheuristicOutput output = await processController.Specific.RunMetaheuristic.ExecuteProcess(input); if (output != null) { Context.Instance.Solutions = output.Solutions; DARPResults = new ResultsViewModel(output.Solutions.First()); ILSEvolution = new ILSEvolutionViewModel(output.Solutions.First()); VNSOperators = new VNSOperatorsViewModel(output.Solutions.First()); AlgorithmSummary = new SummaryResultsViewModel(output.Solutions.First()); ChartsViewModel = new ChartsViewModel(output.Solutions.First()); HeuristicExecuted = true; TabSelected = 1; SetStatus(Constants.StatusType.Ok, String.Format(Properties.Resources.HEURISTIC_EXECUTED_SUCCESFULLY)); } else { SetStatus(Constants.StatusType.Ok, String.Format(Properties.Resources.HEURISTIC_EXECUTED_FAIL)); } } finally { splashController.HideSplash(); } }
public ChartsViewModel GetChartsData() { ChartsViewModel chartsVM = new ChartsViewModel(); GetCategoryChartsData(chartsVM); GetTopVisitedChartsData(chartsVM); GetBestsellers(chartsVM); return(chartsVM); }
// GET: Charts public ActionResult Create() { MedicineModel Model = new MedicineModel(); SelectList MedicineNames = new SelectList(Model.GetNames()); ViewBag.MedicineNames = MedicineNames; ChartsViewModel viewModel = new ChartsViewModel(); return(View(viewModel)); }
public ActionResult LastYear() { ViewBag.Message = "Charts."; ChartsViewModel chartsViewModel = new ChartsViewModel(Average.ChartSpans.LastYear); chartsViewModel.Load(); return(View("Index", chartsViewModel)); }
public ActionResult Index() { ViewBag.Message = "Charts."; ChartsViewModel chartsViewModel = new ChartsViewModel(Average.ChartSpans.Last48Hours); chartsViewModel.Load(); return(View(chartsViewModel)); }
public IActionResult RefreshDashBoard(ChartsViewModel chartsVm) { var highCharts = getCharts(chartsVm.StartDate, chartsVm.EndDate); MemoryCacher.Add(CacheKey.START_DATE.GetDescription(), chartsVm.StartDate, DateTime.Now.AddDays(1)); MemoryCacher.Add(CacheKey.END_DATE.GetDescription(), chartsVm.EndDate, DateTime.Now.AddDays(1)); return(View("DashBoard", new ChartsViewModel { Charts = highCharts, StartDate = chartsVm.StartDate, EndDate = chartsVm.EndDate })); }
public async Task <ChartsViewModel> GetChartsViewModel() { var model = new ChartsViewModel(); model.MostViewedProducts = await this.service.GetMostViewedProductsAsync(); model.MostExpensiveProducts = await this.service.GetMostExpensiveProductsAsync(); return(model); }
private void GetTopVisitedChartsData(ChartsViewModel chartsVM) { chartsVM.TopVisitedData = new List <ChartData>(); foreach (Book b in db.Books.OrderByDescending(b => b.VisitCounter).Take(5)) { ChartData data = new ChartData { Name = b.Title, Count = b.VisitCounter }; chartsVM.TopVisitedData.Add(data); } }
private void GetCategoryChartsData(ChartsViewModel chartsVM) { chartsVM.CategoryData = new List <ChartData>(); foreach (Category c in db.Categories) { ChartData data = new ChartData { Name = c.Name, Count = c.Books.Count }; chartsVM.CategoryData.Add(data); } }
public ActionResult Index() { var redisInfoList = this.ChartsModule.GetRedisInfoData(); var model = new ChartsViewModel(); model.CPUChart = this.ChartsModule.GetCPUInfo(redisInfoList); model.MemoryChart = this.ChartsModule.GetMemoryInfo(redisInfoList); model.CommandProcessedChart = this.ChartsModule.GetCommandProcessedCount(redisInfoList); model.ThroughputChart = this.ChartsModule.GetThroughPutData(redisInfoList); model.TotalKeys = this.ChartsModule.GetRedisTotalKeys(); model.ClientCount = this.ChartsModule.GetRedisClientCount(); return(View(model)); }
public ActionResult Create(FormCollection collection, Charts chart) { string MedicineName = collection.Get("name"); chart.From = new DateTime(chart.From.Year, chart.From.Month, 1); chart.To = new DateTime(chart.To.Year, chart.To.Month, 1); Charts current = new Charts(MedicineName, chart.From, chart.To); ChartsModel model = new ChartsModel(); model.GetChart(current); ChartsViewModel viewModel = new ChartsViewModel(current); TempData["viewModel"] = viewModel; return(RedirectToAction("Index")); }
public async Task <ChartsViewModel> GetViewModel(ClaimsPrincipal user, string babyName, int?maxAge = null) { var result = new ChartsViewModel(); var connection = await _sqLiteService.OpenConnection(user); var entries = _sqLiteService.GetGrowth(long.MinValue, long.MaxValue, babyName, connection); var babies = await _sqLiteService.GetBabiesFromDb(user); var baby = babies.FirstOrDefault(baby => baby.BabyName == babyName) as BabyModel; connection.Close(); foreach (Growth entry in entries.Take(maxAge ?? int.MaxValue)) { var ageInMonths = (entry.TimeUTC - baby.DateOfBirth).Days / (double)30; if (entry.Weight > 0) { result.WeightPoints.Add(new Point(ageInMonths, entry.Weight)); } if (entry.Length > 0) { result.LengthPoints.Add(new Point(ageInMonths, entry.Length)); } if (entry.HeadSize > 0) { result.HeadSizePoints.Add(new Point(ageInMonths, entry.HeadSize)); } if (entry.Length > 0 && entry.Weight > 0) { var lengthInMeters = entry.Length / 100; var bmi = entry.Weight / (lengthInMeters * lengthInMeters); result.BMIPoints.Add(new Point(ageInMonths, bmi)); } } SetWeightCsvPoints(result, maxAge); SetLengthCsvPoints(result, maxAge); SetHeadSizeCsvPoints(result, maxAge); SetBMICsvPoints(result, maxAge); return(result); }
private void GetBestsellers(ChartsViewModel chartsVM) { chartsVM.BestsellersData = new List <ChartData>(); var items = db.OrdersDetails.GroupBy(od => od.BookId) .Select(odg => new { Name = odg.FirstOrDefault().Book.Title, Count = odg.Sum(od => od.Count) }) .OrderByDescending(i => i.Count).Take(5); foreach (var item in items) { ChartData data = new ChartData { Name = item.Name, Count = item.Count }; chartsVM.BestsellersData.Add(data); } }
public ActionResult DateCharts(DateGrouping?grouping, string itemId, bool?accumulative) { var reproduccionesDB = Database.SpawnsCapsulesItems .Where(p => p.SpawnsCapsules.Spawns.UserId == Username) .Select(s => s.ItemId) .Distinct() .ToList(); ChartsViewModel model = new ChartsViewModel(); model.Grouping = grouping ?? DateGrouping.Week; model.Accumulative = accumulative.GetValueOrDefault(); model.ItemId = itemId; model.ViewableItems = ItemsXml.Where(p => reproduccionesDB.Contains(p.ItemId)).Select(q => new { q.ItemId, Description = q.Description() }).ToDictionary(r => r.ItemId, s => s.Description); model.ChartTitle = new ChartTitleViewModel { Grouping = model.Grouping, Item = ItemViewModelLight.Create(ItemsXml, model.ItemId), Accumulative = model.Accumulative }; return(View(model)); }
public JsonResult CampaignDashBoardList(string country, string campaign) // accepts campaign of the country and passes the list of data by JSON call { ChartsViewModel cVM = new ChartsViewModel(); List <string> data = new List <string>(); // asigned the returned list to this and pass it to json parameter try { // here you need to get the data to display it in the chart var response = cVM.GetAllTheDeTailsRelatedToEachCountry(country, campaign); if (!object.Equals(response, null)) { data = response; } } catch (Exception ex) { throw; } return(Json(data, JsonRequestBehavior.AllowGet)); }
public ActionResult Charts() { ChartsViewModel vm = new ChartsViewModel(); vm.Creatures = new List <Creature>(); vm.Filter = new List <SelectListItem> { new SelectListItem { Text = "Population", Selected = false, Value = "Population" }, new SelectListItem { Text = "Species Name", Selected = false, Value = "SpeciesName" }, new SelectListItem { Text = "Author Name", Selected = false, Value = "AuthorName" }, new SelectListItem { Text = "Type", Selected = false, Value = "Type" } }; vm.SelectedCreatures = new List <Creature>(); vm.Versions = new List <SelectListItem> { new SelectListItem { Text = "All Versions", Selected = true, Value = "" }, new SelectListItem { Text = "2.1.0", Selected = true, Value = "2.1.0" } }; vm.StartTimes = new List <SelectListItem> { new SelectListItem { Text = "Last 24 Hours", Selected = true, Value = "" }, }; return(View(vm)); }
// GET: Results/ResultsChart public ActionResult ResultsChart() { String uId = User.Identity.GetUserId(); // get logged in users Id ResultsViewModel rVM = new ResultsViewModel(); // get all the user roles ResultsDTO results = new ResultsDTO(); // List <ResultsDTO> resultsDTO = rVM.GetUsersRole(); bool found = false; foreach (var result in resultsDTO) { if (uId != result.UserId) { found = true; } } CampaignViewModel camVM = new CampaignViewModel(); // get all the campaign List <CampaignDTO> campaign = new List <CampaignDTO>(); campaign = camVM.GetAllCampaigns(); ChartsViewModel cVM = new ChartsViewModel(); RegisterViewModel userDetails = cVM.GetUserDetailsById(uId); // get signed in users details List <string> usersCountryCampainglist = new List <string>(); // get the campaigns name from the list campaings model and add them to string list if (found == true) // if the user exist { foreach (var cam in campaign) { if (userDetails.Country == cam.Country) { if (!usersCountryCampainglist.Contains(cam.Description.ToString())) { usersCountryCampainglist.Add(cam.Description); } } } } //bool isEmpty = !results.Any(); bool isEmpty = !usersCountryCampainglist.Any(); if (!isEmpty) // check if the list is not null than add the values to the object , else redirect the user that there are no campaigns in the country { results.Campagin = usersCountryCampainglist.First(); results.Campaigns = usersCountryCampainglist; ViewBag.Campaign = usersCountryCampainglist.First(); // get the first country for the Campaigns var collectedCampaign = usersCountryCampainglist.First(); // get the first country for the Campaigns CampaignDashBoardList(collectedCampaign); // default draw of the data return(View("~/Views/Results/ResultsChart.cshtml", results)); // return with the values to view. } else { return(View("~/Views/Results/NotFound.cshtml")); // no ca } }
public WindowViewModel(ProductsViewModel productsViewModel, StatisticsViewModel statisticsViewModel, ChartsViewModel chartsViewModel) { ProductsViewModel = productsViewModel; StatisticsViewModel = statisticsViewModel; ChartsViewModel = chartsViewModel; }
public ChartsPage() { InitializeComponent(); BindingContext = viewModel = new ChartsViewModel(); }
/// <summary> /// Initializes a new instance of the ChartsPage class. /// </summary> public ChartsPage() { InitializeComponent(); _vm = DataContext as ChartsViewModel; }
public async Task <IActionResult> ViewSensorData(string id) { _logger.LogInformation($"{nameof(SensorsController.ViewSensorData)} called."); var user = await _userManager.GetUserAsync(User); if (user == null) { return(NotFound($"Unable to load user with ID '{_userManager.GetUserId(User)}'.")); } var tempChartData = new ChartData <double> { Datasets = new List <ChartDataset <double> > { new ChartDataset <double> { Label = "Temperature", YaxisID = "y-axis-1", BorderColor = "rgb(255, 99, 132)", BackgroundColor = "rgb(255, 99, 132)" } } }; var humiChartData = new ChartData <double> { Datasets = new List <ChartDataset <double> > { new ChartDataset <double> { Label = "Humidity", YaxisID = "y-axis-2", BorderColor = "rgb(54, 162, 235)", BackgroundColor = "rgb(54, 162, 235)" } } }; var sensorTemperatureData = await _temperatureService .GetByTimeIntervalGroupedByHour(DateTime.UtcNow.AddDays(-24), sensorId : id) .ToListAsync(); var labels = new List <string>(); foreach (var temp in sensorTemperatureData) { labels.Add(temp.DateTime.ToString(TimeFormat)); tempChartData.Datasets[0].Data.Add(Math.Round(temp.Temperature, 1)); humiChartData.Datasets[0].Data.Add(Math.Round(temp.Humidity, 1)); } tempChartData.Labels = labels; humiChartData.Labels = labels; var chartViewData = new ChartsViewModel { TemperatureChartData = tempChartData, HumidityChartData = humiChartData }; return(View(chartViewData)); }
// GET: Charts public ActionResult Index() { // get the data from the DB ChartsViewModel cVM = new ChartsViewModel(); List <RegisterViewModel> users = cVM.GetAllUsres(); // get the users List <VotesDTO> vots = cVM.GetAllVotes(); // get the votes List <CampaignDTO> campaigns = cVM.GetCampaigns(); // get all the campaigns List <CandidateDTO> candidates = cVM.GetCandidates(); // get all the cadidates data int totalUusers = 0; int totalVots = 0; double totalMale = 0; double totalFemale = 0; double totalOthers = 0; foreach (var item in users) // count total number of users in the system thats registered { if (item.Gender == "Male") { totalMale++; } else if (item.Gender == "Female") { totalFemale++; } else { totalOthers++; } totalUusers++; } // checking the total numbers of votes given by each gender double maleVotes = 0; double femaleVotes = 0; double othersVotes = 0; foreach (var vote in vots) // count total number of votes { foreach (var user in users) { if (vote.UserId == user.UserId && user.Gender == "Male") { maleVotes++; } else if (vote.UserId == user.UserId && user.Gender == "Female") { femaleVotes++; } else if (vote.UserId == user.UserId && user.Gender == "Other") { othersVotes++; } } totalVots++; } ////calculate the precentage of each gender out of total //double totalGenders = totalMale + totalFemale + totalOthers; //if (totalGenders != 0) //{ // totalMale = (totalMale * 100) / totalGenders; // totalFemale = (totalFemale * 100) / totalGenders; // totalOthers = (totalOthers * 100) / totalGenders; //} //else //{ // totalMale = 0; // totalFemale = 0; // totalOthers = 0; //} //totalMale = Math.Round(totalMale); //totalFemale = Math.Round(totalFemale); //totalOthers = Math.Round(totalOthers); // NEXT BAR CHART // you can get the country now and within that you need to get how many campaigns are in the country and how many candidates are in each campaign //to following is just for demo day ///////////////////////////////////DEMO/////////////////////////DEMO///////////////////DEMO/////////////DEMO totalUusers = 1106500000; totalVots = 905000000; totalMale = 531120000; totalFemale = 442600000; totalOthers = 132780000; ///////////////////////////////////DEMO/////////////////////////DEMO///////////////////DEMO/////////////DEMO // the following values just for the demo ///////////////////////////////////DEMO/////////////////////////DEMO///////////////////DEMO/////////////DEMO maleVotes = 470600000; femaleVotes = 362000000; othersVotes = 72400000; ////////////////////////////////////DEMO////////////DEMO/////////////DEMO//////////////DEMO////////////////DEMO//////////////DEMO////////////// ViewBag.totalUsers = totalUusers; ViewBag.totalVots = totalVots; ViewBag.totalMale = totalMale; ViewBag.totalFemale = totalFemale; ViewBag.totalOters = totalOthers; ViewBag.maleVotes = maleVotes; ViewBag.femaleVotes = femaleVotes; ViewBag.othersVotes = othersVotes; return(View()); }
public Country GetChartData() { Country objproduct = new Country(); /*Get the data from databse and prepare the chart record data in string form.*/ ChartsViewModel cVM = new ChartsViewModel(); List <RegisterViewModel> users = cVM.GetAllUsres(); // get the users List <CampaignDTO> campaigns = cVM.GetCampaigns(); // get all the campaigns List <VotesDTO> votes = cVM.GetAllVotes(); // get the votes objproduct.CountryName = ""; foreach (var country in users) // get list of countries from registered users, if there are no campaigns still i want to see users region on GEO MAP { foreach (var item in users) { if (country.Country == item.Country) { if (!objproduct.CountryName.Contains(country.Country.ToString())) { objproduct.CountryName += country.Country + ","; } } } } foreach (var country in campaigns) // get list of the countries from the campaigns { foreach (var item in campaigns) { if (country.Country == item.Country) { if (!objproduct.CountryName.Contains(country.Country.ToString())) { objproduct.CountryName += country.Country + ","; } } } } // remove the last comma from the string var countries = objproduct.CountryName.TrimEnd(',', ' '); ViewBag.Test = countries; // get the population of each of the country thats registered in the system. // get the total votes are give in the system from that country var countryarray = countries.Split(','); objproduct.Registerd = ""; int countUsers = 0; int countVote = 0; int counCampaign = 0; bool found = false; bool voteFound = false; bool camFound = false; foreach (var country in countryarray) { foreach (var user in users) { if (country.ToString() == user.Country.ToString()) // match the country related to the users and count the populations { countUsers++; found = true; foreach (var vote in votes) { if (user.UserId == vote.UserId) // get the users vote in each country and county the total of the vote for particular country { countVote++; voteFound = true; } } //foreach(var cam in campaigns) //{ // if(country == cam.Country) // { // counCampaign++; // camFound = true; // } //} } } if (found == true && voteFound == true /* & camFound == true*/) // if it's true than add the values to the string { objproduct.Registerd += countUsers + ","; objproduct.Vote += countVote + ","; countUsers = 0; countVote = 0; } } //var countries = objproduct.CountryName.TrimEnd(',', ' '); var Registerd = objproduct.Registerd.TrimEnd(',', ' '); // remove the comman or space at the end of the line var Vote = objproduct.Vote.TrimEnd(',', ' '); //Test them at the View. ViewBag.Test1 = Registerd; ViewBag.Test2 = Vote; //// the following are just the value that will show system features on demo day///////////////////////////////////DEMO/////////////////////////DEMO///////////////////DEMO/////////////DEMO objproduct.CountryName = "Ireland,Afghanistan,Australia,USA,United Kingdom,colombia,India,South Africa,Brazil,Russia"; objproduct.Registerd = "4500000,10000000,15000000,135000000,46000000,40000000,650000000,26000000,120000000,60000000"; objproduct.Vote = "4000000,7000000,12000000,120000000,44000000,35000000,500000000,25000000,100000000,58000000"; ///////////////////////////////////DEMO/////////////////////////DEMO///////////////////DEMO/////////////DEMO///////////////////////////////////DEMO/////////////////////////DEMO//////////// return(objproduct); }
public Charts() { InitializeComponent(); DataContext = new ChartsViewModel(); }