// ------------------------- Distributions ------------------------------------

        public StatisticDataset GetCacheDistributionBySize(DataFilter filter)
        {
            filterManager.ValidateFilter(filter);
            var data = new StatisticDataset {
                Data           = cacheDao.GetCacheDistributionBySize(filter),
                Caption        = "Distribution of caches by size",
                Column2Caption = "Category of size",
                Column3Caption = "Share [%]"
            };

            return(data);
        }
        public StatisticDataset GetCacheDistributionByTerrainDifficulty(DataFilter filter)
        {
            filterManager.ValidateFilter(filter);
            var data = new StatisticDataset {
                Data           = cacheDao.GetCacheDistributionByTerrainDifficulty(filter),
                Caption        = "Distribution of caches by terrain difficulty",
                Column2Caption = "Difficulty Level",
                Column3Caption = "Share [%]"
            };

            return(data);
        }
        public StatisticDataset GetCachesByLogCount(DataFilter filter)
        {
            filterManager.ValidateFilter(filter);
            var data = new StatisticDataset {
                Data           = logEntryDao.GetMostLoggedCaches(filter),
                Caption        = "Most logged caches",
                Column2Caption = "Cache name",
                Column3Caption = "Count of log entries"
            };

            return(data);
        }
        public StatisticDataset GetCachesByRating(DataFilter filter)
        {
            filterManager.ValidateFilter(filter);
            var data = new StatisticDataset {
                Data           = cacheDao.GetBestRatedCaches(filter),
                Caption        = "Best rated caches",
                Column2Caption = "Cache name",
                Column3Caption = "Rating [1 - 10]"
            };

            return(data);
        }
        public StatisticDataset GetUsersByHiddenCaches(DataFilter filter)
        {
            filterManager.ValidateFilter(filter);
            var data = new StatisticDataset {
                Data           = cacheDao.GetHiddenCachesCountPerUser(filter),
                Caption        = "Users ordered by number of hidden caches",
                Column2Caption = "Username",
                Column3Caption = "Hidden caches"
            };

            return(data);
        }
        // ------------------------- Top Lists ------------------------------------

        public StatisticDataset GetUsersByFoundCaches(DataFilter filter)
        {
            filterManager.ValidateFilter(filter);
            var data = new StatisticDataset {
                Data           = logEntryDao.GetFoundCachesCountPerUser(filter),
                Caption        = "Users ordered by number of found caches",
                Column2Caption = "Username",
                Column3Caption = "Found caches"
            };

            return(data);
        }
        public IActionResult Index()
        {
            Dictionary <string, StatisticShowModel> models = new Dictionary <string, StatisticShowModel>();

            StatisticShowModel model = new StatisticShowModel()
            {
                type = "bar", id = "statChartAccounts"
            };
            IEnumerable <AccountModel> accounts  = _context.Accounts.ToList();
            Dictionary <int, int>      IdToIndex = new Dictionary <int, int>();
            int index = 0;

            model.data.labels.Add("24h");
            //model.data.labels.Add("72h");

            foreach (AccountModel acc in accounts)
            {
                StatisticDataset data = new StatisticDataset()
                {
                    label = acc.Username
                };
                data.fill = true;

                data.data.Add(Math.Round(acc.TrafficLeft, 0));

                model.data.datasets.Add(data);
                IdToIndex.Add(acc.ID, index);
                index++;
            }
            models.Add("accounts", model);

            ViewData["idToIndex"] = Newtonsoft.Json.JsonConvert.SerializeObject(IdToIndex);

            model = new StatisticShowModel()
            {
                id = "statChartDownload"
            };
            StatisticDataset datal = new StatisticDataset()
            {
                label = "Geschwindigkeit MB/s"
            };

            model.data.labels.Add(DateTime.Now.ToString());
            datal.data.Add(0);
            model.data.datasets.Add(datal);
            models.Add("download", model);

            return(View(models));
        }