public IAggregatedChartViewModel CreateAggregatedChartViewModel()
        {
            IReadOnlyCollection <LapTelemetryDto> loadedLaps = _loadedLapsCache.LoadedLaps;
            string title = $"{ChartName} - Laps: {string.Join(", ", loadedLaps.Select(x => x.LapSummary.CustomDisplayName))}";

            int maxGear = loadedLaps.SelectMany(x => x.TimedTelemetrySnapshots).Where(x => !string.IsNullOrWhiteSpace(x.PlayerData.CarInfo.CurrentGear) && x.PlayerData.CarInfo.CurrentGear != "R" && x.PlayerData.CarInfo.CurrentGear != "N").Max(x => int.Parse(x.PlayerData.CarInfo.CurrentGear));

            CompositeAggregatedChartsViewModel viewModel = new CompositeAggregatedChartsViewModel()
            {
                Title = title
            };

            HistogramChartViewModel mainViewModel = _viewModelFactory.Create <HistogramChartViewModel>();

            mainViewModel.FromModel(CreateHistogramAllGears(loadedLaps, _rpmHistogramDataExtractor.DefaultBandSize));

            viewModel.MainAggregatedChartViewModel = mainViewModel;

            for (int i = 1; i <= maxGear; i++)
            {
                Histogram histogram = CreateHistogram(loadedLaps, i, _rpmHistogramDataExtractor.DefaultBandSize);
                if (histogram == null)
                {
                    continue;
                }
                HistogramChartViewModel child = _viewModelFactory.Create <HistogramChartViewModel>();
                child.FromModel(histogram);
                viewModel.AddChildAggregatedChildViewModel(child);
            }

            return(viewModel);
        }
        // Chart
        public async Task <List <HistogramChartViewModel> > GetHistogrmChartCountAsync(string createdTime)
        {
            List <HistogramChartViewModel> histogramCharts = new List <HistogramChartViewModel>();

            var query = from g in context.Garbages
                        join sub in context.GCSubCategories on g.SubId equals sub.SubId
                        join cate in context.GCCategories on sub.CategoryId equals cate.CategoryId
                        where g.CreatedTime.ToString("yyyy-MM-dd") == createdTime
                        group new { g.GCSubCategories.GCCategories, g } by new {
                g.GCSubCategories.GCCategories.CategoryId,
                g.GCSubCategories.GCCategories.CategoryName
            } into g
                select new HistogramChartViewModel {
                Qty          = g.Sum(p => p.g.RecyclingQty),
                CategoryName = g.Key.CategoryName
            };

            if (query.Any())
            {
                foreach (var item in query)
                {
                    var histogram = new HistogramChartViewModel();
                    histogram.Qty          = item.Qty;
                    histogram.CategoryName = item.CategoryName;
                    histogramCharts.Add(histogram);
                }
            }
            return(histogramCharts);
        }
Beispiel #3
0
        public override IReadOnlyCollection <IAggregatedChartViewModel> CreateAggregatedChartViewModels(AggregatedChartSettingsDto aggregatedChartSettings)
        {
            List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>();
            var groupedByStint = GetLapsGrouped(aggregatedChartSettings);

            foreach (IGrouping <int, LapTelemetryDto> lapsInStint in groupedByStint)
            {
                string title = BuildChartTitle(lapsInStint, aggregatedChartSettings);

                HistogramChartViewModel viewModel = _viewModelFactory.Create <HistogramChartViewModel>();
                viewModel.IsBandVisible  = true;
                viewModel.Title          = title;
                viewModel.Unit           = _speedHistogramExtractor.YUnit;
                viewModel.BandSize       = _speedHistogramExtractor.DefaultBandSize;
                viewModel.RefreshCommand = new RelayCommand(() => FillHistogramViewmodel(lapsInStint.ToList(), viewModel));
                FillHistogramViewmodel(lapsInStint.ToList(), viewModel);
                charts.Add(viewModel);
            }

            return(charts);
        }
Beispiel #4
0
        public override IReadOnlyCollection <IAggregatedChartViewModel> CreateAggregatedChartViewModels(AggregatedChartSettingsDto aggregatedChartSettings)
        {
            List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>();
            var groupedByStint = GetLapsGrouped(aggregatedChartSettings);

            foreach (IGrouping <int, LapTelemetryDto> lapsInStint in groupedByStint)
            {
                string title = BuildChartTitle(lapsInStint, aggregatedChartSettings);

                int maxGear = lapsInStint.SelectMany(x => x.DataPoints).Where(x => !string.IsNullOrWhiteSpace(x.PlayerData.CarInfo.CurrentGear) && x.PlayerData.CarInfo.CurrentGear != "R" && x.PlayerData.CarInfo.CurrentGear != "N").Max(x => int.Parse(x.PlayerData.CarInfo.CurrentGear));

                CompositeAggregatedChartsViewModel viewModel = new CompositeAggregatedChartsViewModel()
                {
                    Title = title
                };

                HistogramChartViewModel mainViewModel = _viewModelFactory.Create <HistogramChartViewModel>();
                mainViewModel.FromModel(CreateHistogramAllGears(lapsInStint, _rpmHistogramDataExtractor.DefaultBandSize));

                viewModel.MainAggregatedChartViewModel = mainViewModel;

                for (int i = 1; i <= maxGear; i++)
                {
                    Histogram histogram = CreateHistogram(lapsInStint, i, _rpmHistogramDataExtractor.DefaultBandSize);
                    if (histogram == null)
                    {
                        continue;
                    }

                    HistogramChartViewModel child = _viewModelFactory.Create <HistogramChartViewModel>();
                    child.FromModel(histogram);
                    viewModel.AddChildAggregatedChildViewModel(child);
                }
                charts.Add(viewModel);
            }

            return(charts);
        }
Beispiel #5
0
 private void FillHistogramViewmodel(IReadOnlyCollection <LapTelemetryDto> loadedLaps, HistogramChartViewModel viewModel)
 {
     viewModel.FromModel(_speedHistogramExtractor.ExtractHistogram(loadedLaps, _filter, viewModel.BandSize, viewModel.Title));
 }
Beispiel #6
0
 private void RefreshHistogram(IReadOnlyCollection <LapTelemetryDto> loadedLaps, HistogramChartViewModel viewModel)
 {
     FillHistogramViewmodel(loadedLaps, viewModel);
 }