private IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForAllStints(List <IGrouping <int, LapTelemetryDto> > lapsStintGrouping)
        {
            _dataExtractor.ThrottlePositionFilter.Minimum = double.MinValue;
            _dataExtractor.ThrottlePositionFilter.Maximum = double.MaxValue;
            IColorPaletteProvider colorPaletteProvider = new BasicColorPaletteProvider();
            string title = BuildTitleForAllStints(lapsStintGrouping);

            List <ScatterPlotSeries> leftFrontWheelSeries  = new List <ScatterPlotSeries>();
            List <ScatterPlotSeries> rightFrontWheelSeries = new List <ScatterPlotSeries>();
            List <ScatterPlotSeries> leftRearWheelSeries   = new List <ScatterPlotSeries>();
            List <ScatterPlotSeries> rightRearWheelSeries  = new List <ScatterPlotSeries>();

            foreach (IGrouping <int, LapTelemetryDto> lapsGrouped in lapsStintGrouping)
            {
                OxyColor color       = colorPaletteProvider.GetNext().ToOxyColor();
                string   seriesTitle = $"Laps: {string.Join(", ", lapsGrouped.Select(x => x.LapSummary.CustomDisplayName))} - Stint: {lapsGrouped.Key}";
                leftFrontWheelSeries.Add(_dataExtractor.ExtractFrontLeft(lapsGrouped, "FL :" + seriesTitle, color));
                rightFrontWheelSeries.Add(_dataExtractor.ExtractFrontRight(lapsGrouped, "FR :" + seriesTitle, color));
                leftRearWheelSeries.Add(_dataExtractor.ExtractRearLeft(lapsGrouped, "RL :" + seriesTitle, color));
                rightRearWheelSeries.Add(_dataExtractor.ExtractRearRight(lapsGrouped, "RR :" + seriesTitle, color));
            }

            WheelsChartViewModel mainViewModel = new WheelsChartViewModel()
            {
                Title = title,
                FrontLeftChartViewModel  = CreateScatterPlotChartViewModel("Front Left", leftFrontWheelSeries.ToArray()),
                FrontRightChartViewModel = CreateScatterPlotChartViewModel("Front Right", rightFrontWheelSeries.ToArray()),
                RearLeftChartViewModel   = CreateScatterPlotChartViewModel("Rear Left", leftRearWheelSeries.ToArray()),
                RearRightChartViewModel  = CreateScatterPlotChartViewModel("Rear Right", rightRearWheelSeries.ToArray())
            };

            return(new[] { mainViewModel });
        }
        public IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForEachStint(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping, AggregatedChartSettingsDto aggregatedChartSettings)
        {
            IColorPaletteProvider            colorPaletteProvider = new ColorRangePaletteProvider(FromColor, ToColor, ColorSteps);
            List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>();
            double throttleStep = 1.0 / (colorPaletteProvider.PaletteSize - 1);

            foreach (IGrouping <int, LapTelemetryDto> lapsGrouped in lapsStintGrouping)
            {
                string title = BuildChartTitle(lapsGrouped, aggregatedChartSettings);
                List <ScatterPlotSeries> leftFrontWheelSeries  = new List <ScatterPlotSeries>();
                List <ScatterPlotSeries> rightFrontWheelSeries = new List <ScatterPlotSeries>();
                List <ScatterPlotSeries> leftRearWheelSeries   = new List <ScatterPlotSeries>();
                List <ScatterPlotSeries> rightRearWheelSeries  = new List <ScatterPlotSeries>();

                colorPaletteProvider.Reset();

                OxyColor color;
                string   throttleLabel;
                string   seriesTitle;

                for (int i = 0; i < colorPaletteProvider.PaletteSize - 1; i++)
                {
                    color = colorPaletteProvider.GetNext().ToOxyColor();
                    _dataExtractor.ThrottlePositionFilter.Minimum = throttleStep * i;
                    _dataExtractor.ThrottlePositionFilter.Maximum = throttleStep * (i + 1);
                    throttleLabel = $"Throttle: {_dataExtractor.ThrottlePositionFilter.Minimum * 100:F0} - {_dataExtractor.ThrottlePositionFilter.Maximum * 100:F0}";
                    seriesTitle   = $"Stint: {lapsGrouped.Key} " + throttleLabel;

                    leftFrontWheelSeries.Add(_dataExtractor.ExtractFrontLeft(lapsGrouped, "FL :" + seriesTitle, color));
                    rightFrontWheelSeries.Add(_dataExtractor.ExtractFrontRight(lapsGrouped, "FR :" + seriesTitle, color));
                    leftRearWheelSeries.Add(_dataExtractor.ExtractRearLeft(lapsGrouped, "RL :" + seriesTitle, color));
                    rightRearWheelSeries.Add(_dataExtractor.ExtractRearRight(lapsGrouped, "RR :" + seriesTitle, color));
                }

                color = colorPaletteProvider.GetNext().ToOxyColor();
                _dataExtractor.ThrottlePositionFilter.Minimum = 1;
                _dataExtractor.ThrottlePositionFilter.Maximum = double.MaxValue;
                throttleLabel = $"Throttle: 100";
                seriesTitle   = $"Stint: {lapsGrouped.Key} " + throttleLabel;

                leftFrontWheelSeries.Add(_dataExtractor.ExtractFrontLeft(lapsGrouped, "FL :" + seriesTitle, color));
                rightFrontWheelSeries.Add(_dataExtractor.ExtractFrontRight(lapsGrouped, "FR :" + seriesTitle, color));
                leftRearWheelSeries.Add(_dataExtractor.ExtractRearLeft(lapsGrouped, "RL :" + seriesTitle, color));
                rightRearWheelSeries.Add(_dataExtractor.ExtractRearRight(lapsGrouped, "RR :" + seriesTitle, color));

                WheelsChartViewModel mainViewModel = new WheelsChartViewModel()
                {
                    Title = title,
                    FrontLeftChartViewModel  = CreateScatterPlotChartViewModel("Front Left", leftFrontWheelSeries.ToArray()),
                    FrontRightChartViewModel = CreateScatterPlotChartViewModel("Front Right", rightFrontWheelSeries.ToArray()),
                    RearLeftChartViewModel   = CreateScatterPlotChartViewModel("Rear Left", leftRearWheelSeries.ToArray()),
                    RearRightChartViewModel  = CreateScatterPlotChartViewModel("Rear Right", rightRearWheelSeries.ToArray())
                };

                charts.Add(mainViewModel);
            }

            return(charts);
        }
Esempio n. 3
0
        private WheelsChartViewModel CreateWheelsChartViewModel(ScatterPlotSeries fl, ScatterPlotSeries fr, ScatterPlotSeries rl, ScatterPlotSeries rr)
        {
            WheelsChartViewModel wheelsChartViewModel = new WheelsChartViewModel
            {
                FrontLeftChartViewModel  = CreateScatterPlotChartViewModel("Front Left", fl),
                FrontRightChartViewModel = CreateScatterPlotChartViewModel("Front Right", fr),
                RearLeftChartViewModel   = CreateScatterPlotChartViewModel("Rear Left", rl),
                RearRightChartViewModel  = CreateScatterPlotChartViewModel("Rear Right", rr)
            };

            return(wheelsChartViewModel);
        }
Esempio n. 4
0
        protected void FillHistogramViewmodel <T>(IReadOnlyCollection <LapTelemetryDto> loadedLaps, double bandSize, WheelsChartViewModel wheelsChart) where T : HistogramChartViewModel
        {
            Histogram flHistogram = _abstractWheelHistogramDataExtractor.ExtractHistogramFrontLeft(loadedLaps, bandSize);
            Histogram frHistogram = _abstractWheelHistogramDataExtractor.ExtractHistogramFrontRight(loadedLaps, bandSize);
            Histogram rlHistogram = _abstractWheelHistogramDataExtractor.ExtractHistogramRearLeft(loadedLaps, bandSize);
            Histogram rrHistogram = _abstractWheelHistogramDataExtractor.ExtractHistogramRearRight(loadedLaps, bandSize);

            T flViewModel = _viewModelFactory.Create <T>();

            flViewModel.FromModel(flHistogram);

            T frViewModel = _viewModelFactory.Create <T>();

            frViewModel.FromModel(frHistogram);

            T rlViewModel = _viewModelFactory.Create <T>();

            rlViewModel.FromModel(rlHistogram);

            T rrViewModel = _viewModelFactory.Create <T>();

            rrViewModel.FromModel(rrHistogram);

            wheelsChart.FrontLeftChartViewModel  = flViewModel;
            wheelsChart.FrontRightChartViewModel = frViewModel;
            wheelsChart.RearLeftChartViewModel   = rlViewModel;
            wheelsChart.RearRightChartViewModel  = rrViewModel;
        }