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);
        }
        private IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForEachStint(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping, AggregatedChartSettingsDto aggregatedChartSettings)
        {
            List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>();

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

                int maxGear = lapsGrouped.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
                };

                ScatterPlotChartViewModel mainViewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization)
                {
                    Title = "All Gear"
                };
                mainViewModel.FromModel(CreateScatterPlotAllGear(lapsGrouped, maxGear));

                viewModel.MainAggregatedChartViewModel = mainViewModel;

                for (int i = 1; i <= maxGear; i++)
                {
                    ScatterPlot scatterPlot = CreateScatterPlot(lapsGrouped, i);
                    if (scatterPlot.ScatterPlotSeries.Count == 0)
                    {
                        continue;
                    }

                    ScatterPlotChartViewModel child = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization)
                    {
                        Title = $"Gear {i}"
                    };
                    child.FromModel(scatterPlot);
                    viewModel.AddChildAggregatedChildViewModel(child);
                }

                charts.Add(viewModel);
            }

            return(charts);
        }
        private IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForAllStints(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping)
        {
            IGrouping <int, LapTelemetryDto>[] lapsInStints = lapsStintGrouping as IGrouping <int, LapTelemetryDto>[] ?? lapsStintGrouping.ToArray();
            string title   = BuildTitleForAllStints(lapsInStints);
            int    maxGear = lapsInStints.SelectMany(x => x).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
            };

            ScatterPlotChartViewModel mainViewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization)
            {
                Title = "All Gear"
            };

            mainViewModel.FromModel(CreateScatterPlotAllGear(lapsInStints, maxGear));
            viewModel.MainAggregatedChartViewModel = mainViewModel;

            for (int i = 1; i <= maxGear; i++)
            {
                ScatterPlot scatterPlot = CreateScatterPlot(lapsInStints, i);
                if (scatterPlot.ScatterPlotSeries.Count == 0)
                {
                    continue;
                }

                ScatterPlotChartViewModel child = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization)
                {
                    Title = $"Gear {i}"
                };
                child.FromModel(scatterPlot);
                viewModel.AddChildAggregatedChildViewModel(child);
            }

            return(new List <IAggregatedChartViewModel>()
            {
                viewModel
            });
        }
        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
            };

            ScatterPlotChartViewModel mainViewModel = new ScatterPlotChartViewModel()
            {
                Title = "All Gear"
            };

            mainViewModel.FromModel(CreateScatterPlotAllGear(loadedLaps, maxGear));

            viewModel.MainAggregatedChartViewModel = mainViewModel;

            for (int i = 1; i <= maxGear; i++)
            {
                ScatterPlot scatterPlot = CreateScatterPlot(loadedLaps, i);
                if (scatterPlot.ScatterPlotSeries.Count == 0)
                {
                    continue;
                }

                ScatterPlotChartViewModel child = new ScatterPlotChartViewModel()
                {
                    Title = $"Gear {i}"
                };
                child.FromModel(scatterPlot);
                viewModel.AddChildAggregatedChildViewModel(child);
            }

            return(viewModel);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
0
        public IReadOnlyCollection <IAggregatedChartViewModel> CreateAggregatedChartViewModels(AggregatedChartSettingsDto aggregatedChartSettings)
        {
            var histogramChartSettings = aggregatedChartSettings.StintRenderingKind == StintRenderingKind.SingleChart ? new AggregatedChartSettingsDto() : aggregatedChartSettings;
            var mainViewModels         = _latToLogGProvider.CreateAggregatedChartViewModels(aggregatedChartSettings).ToList();
            var speedInTurnsModels     = _speedInTurnsHistogramProvider.CreateAggregatedChartViewModels(histogramChartSettings).ToList();
            var latGViewModels         = _speedToLatGProvider.CreateAggregatedChartViewModels(aggregatedChartSettings).ToList();
            var longGViewModels        = _speedToLongGProvider.CreateAggregatedChartViewModels(aggregatedChartSettings).ToList();

            var compositeViewModels = new List <IAggregatedChartViewModel>();

            for (int i = 0; i < mainViewModels.Count; i++)
            {
                var newCompositeViewModel = new CompositeAggregatedChartsViewModel {
                    Title = mainViewModels[i].Title, MainAggregatedChartViewModel = mainViewModels[i]
                };
                if (i < speedInTurnsModels.Count)
                {
                    newCompositeViewModel.AddChildAggregatedChildViewModel(speedInTurnsModels[i]);
                }


                if (i < latGViewModels.Count)
                {
                    newCompositeViewModel.AddChildAggregatedChildViewModel(latGViewModels[i]);
                }

                if (i < longGViewModels.Count)
                {
                    newCompositeViewModel.AddChildAggregatedChildViewModel(longGViewModels[i]);
                }

                compositeViewModels.Add(newCompositeViewModel);
            }

            return(compositeViewModels);
        }