public static void Main2() { RGBABitmapImageReference imageReference = CreateRGBABitmapImageReference(); ScatterPlotSeries series = GetDefaultScatterPlotSeriesSettings(); series.xs = new double [] { -2, -1, 0, 1, 2 }; series.ys = new double [] { 2, -1, -2, -1, 2 }; series.linearInterpolation = true; series.lineType = "dashed".ToCharArray(); series.lineThickness = 2d; series.color = GetGray(0.3); ScatterPlotSettings settings = GetDefaultScatterPlotSettings(); settings.width = 600; settings.height = 400; settings.autoBoundaries = true; settings.autoPadding = true; settings.title = "x^2 - 2".ToCharArray(); settings.xLabel = "X axis".ToCharArray(); settings.yLabel = "Y axis".ToCharArray(); settings.scatterPlotSeries = new ScatterPlotSeries [] { series }; DrawScatterPlotFromSettings(imageReference, settings); double[] pngdata = ConvertToPNG(imageReference.image); WriteToFile(pngdata, "example2.png"); DeleteImage(imageReference.image); }
private IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForAllStints(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping) { var lapsInStints = lapsStintGrouping as IGrouping <int, LapTelemetryDto>[] ?? lapsStintGrouping.ToArray(); string title = BuildTitleForAllStints(lapsInStints); IColorPaletteProvider colorPaletteProvider = new BasicColorPaletteProvider(); AxisDefinition xAxis = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit, "Rear Roll Angle"); AxisDefinition yAxis = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit, "Front Roll Angle"); ScatterPlot scatterPlot = new ScatterPlot(title, xAxis, yAxis); _lateralAccFilter.MinimumG = 0; _lateralAccFilter.MaximumG = double.MaxValue; foreach (IGrouping <int, LapTelemetryDto> lapsInStint in lapsInStints) { string seriesTitle = BuildSeriesTitle(lapsInStint); ScatterPlotSeries newSeries = _dataExtractor.ExtractSeries(lapsInStint, _filters, seriesTitle, colorPaletteProvider.GetNext().ToOxyColor()); scatterPlot.AddScatterPlotSeries(newSeries); } scatterPlot.AddAnnotation(new LineAnnotation() { Slope = 1, Intercept = 0, Color = OxyColors.Red, StrokeThickness = 1, LineStyle = LineStyle.Solid }); ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization) { Title = title }; viewModel.FromModel(scatterPlot); return(new[] { viewModel }); }
private IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForAllStints(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping) { IColorPaletteProvider colorPaletteProvider = new BasicColorPaletteProvider(); List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>(); IEnumerable <IGrouping <int, LapTelemetryDto> > lapsInStints = lapsStintGrouping as IGrouping <int, LapTelemetryDto>[] ?? lapsStintGrouping.ToArray(); string title = BuildTitleForAllStints(lapsInStints); double maxG = 0; AxisDefinition xAxis = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit, "Lat Acc"); AxisDefinition yAxis = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit, "Long Acc"); ScatterPlot scatterPlot = new ScatterPlot(title, xAxis, yAxis); foreach (IGrouping <int, LapTelemetryDto> lapsInStint in lapsInStints) { string seriesTitle = $"Laps: {string.Join(", ", lapsInStint.Select(x => x.LapSummary.CustomDisplayName))} - Stint: {lapsInStint.Key}"; ScatterPlotSeries newSeries = _dataExtractor.ExtractSeries(lapsInStint, Enumerable.Empty <ITelemetryFilter>().ToList(), seriesTitle, colorPaletteProvider.GetNext().ToOxyColor()); scatterPlot.AddScatterPlotSeries(newSeries); maxG = Math.Max(maxG, newSeries.DataPoints.Max(x => Math.Abs(x.Y))); } SetAxisRanges(maxG, xAxis, yAxis); ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization) { Title = "Lateral / Longitudinal G" }; viewModel.FromModel(scatterPlot); charts.Add(viewModel); return(charts); }
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); }
public ScatterPlotSeries ExtractMultiPointSeries(IEnumerable <LapTelemetryDto> loadedLaps, IReadOnlyCollection <ITelemetryFilter> filters, string seriesTitle, OxyColor color) { TimedTelemetrySnapshot[] timedTelemetrySnapshots = loadedLaps.SelectMany(x => x.DataPoints).Where(x => filters.All(y => y.Accepts(x))).ToArray(); if (timedTelemetrySnapshots.Length == 0) { return(null); } ScatterPlotSeries newSeries = new ScatterPlotSeries(color, seriesTitle); timedTelemetrySnapshots.ForEach(x => newSeries.AddDataPoints(GetDataPoints(x).Select(y => (y.x, y.y, x)))); return(newSeries); }
public IAggregatedChartViewModel CreateAggregatedChartViewModel() { IReadOnlyCollection <LapTelemetryDto> loadedLaps = _loadedLaps.LoadedLaps; string title = $"{ChartName} - Laps: {string.Join(", ", loadedLaps.Select(x => x.LapSummary.CustomDisplayName))}"; ScatterPlotSeries frontLeftSeries = _dataExtractor.ExtractFrontLeft(loadedLaps); ScatterPlotSeries frontRightSeries = _dataExtractor.ExtractFrontRight(loadedLaps); ScatterPlotSeries rearLeftSeries = _dataExtractor.ExtractRearLeft(loadedLaps); ScatterPlotSeries rearRightSeries = _dataExtractor.ExtractRearRight(loadedLaps); SplitAggregatedChartViewModel mainViewModel = new SplitAggregatedChartViewModel() { Title = title, TopViewModel = CreateScatterPlotChartViewModel("All Wheels", frontLeftSeries, frontRightSeries, rearLeftSeries, rearRightSeries), BottomViewModel = CreateWheelsChartViewModel(frontLeftSeries, frontRightSeries, rearLeftSeries, rearRightSeries) }; return(mainViewModel); }
public IReadOnlyCollection <IAggregatedChartViewModel> CreateChartForEachStint(IEnumerable <IGrouping <int, LapTelemetryDto> > lapsStintGrouping, AggregatedChartSettingsDto aggregatedChartSettings) { List <IAggregatedChartViewModel> charts = new List <IAggregatedChartViewModel>(); foreach (IGrouping <int, LapTelemetryDto> lapsInStint in lapsStintGrouping) { string title = BuildChartTitle(lapsInStint, aggregatedChartSettings); AxisDefinition xAxis = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit, "Rear Roll Angle"); AxisDefinition yAxis = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit, "Front Roll Angle"); ScatterPlot scatterPlot = new ScatterPlot(title, xAxis, yAxis); for (int i = 0; i < ColorMap.Count; i++) { double minG = i * 0.25; double maxG = i + 1 == ColorMap.Count ? double.MaxValue : (i + 1) * 0.25; _lateralAccFilter.MinimumG = minG; _lateralAccFilter.MaximumG = maxG; string seriesTitle = maxG < double.MaxValue ? $"{minG:F2}G - {maxG:F2}G" : $"{minG:F2}G+"; ScatterPlotSeries newSeries = _dataExtractor.ExtractSeries(lapsInStint, _filters, seriesTitle, ColorMap[i]); if (newSeries == null) { continue; } } scatterPlot.AddAnnotation(new LineAnnotation() { Slope = 1, Intercept = 0, Color = OxyColors.Red, StrokeThickness = 1, LineStyle = LineStyle.Solid }); ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel(_dataPointSelectionSynchronization) { Title = title }; viewModel.FromModel(scatterPlot); charts.Add(viewModel); } return(charts); }
public 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); ScatterPlotSeries frontLeftSeries = _dataExtractor.ExtractFrontLeft(lapsGrouped); ScatterPlotSeries frontRightSeries = _dataExtractor.ExtractFrontRight(lapsGrouped); ScatterPlotSeries rearLeftSeries = _dataExtractor.ExtractRearLeft(lapsGrouped); ScatterPlotSeries rearRightSeries = _dataExtractor.ExtractRearRight(lapsGrouped); SplitAggregatedChartViewModel mainViewModel = new SplitAggregatedChartViewModel() { Title = title, TopViewModel = CreateScatterPlotChartViewModel("All Wheels", frontLeftSeries, frontRightSeries, rearLeftSeries, rearRightSeries), BottomViewModel = CreateWheelsChartViewModel(frontLeftSeries, frontRightSeries, rearLeftSeries, rearRightSeries) }; charts.Add(mainViewModel); } return(charts); }
public IAggregatedChartViewModel CreateAggregatedChartViewModel() { IReadOnlyCollection <LapTelemetryDto> loadedLaps = _loadedLapsCache.LoadedLaps; string title = $"{ChartName} - Laps: {string.Join(", ", loadedLaps.Select(x => x.LapSummary.CustomDisplayName))}"; AxisDefinition xAxis = new AxisDefinition(_dataExtractor.XMajorTickSize, _dataExtractor.XMajorTickSize / 4, _dataExtractor.XUnit, "Rear Roll Angle"); AxisDefinition yAxis = new AxisDefinition(_dataExtractor.YMajorTickSize, _dataExtractor.YMajorTickSize / 4, _dataExtractor.YUnit, "Front Roll Angle"); ScatterPlot scatterPlot = new ScatterPlot(title, xAxis, yAxis); for (int i = 0; i < ColorMap.Count; i++) { double minG = i * 0.25; double maxG = i + 1 == ColorMap.Count ? double.MaxValue : (i + 1) * 0.25; _lateralAccFilter.MinimumG = minG; _lateralAccFilter.MaximumG = maxG; string seriesTitle = maxG < double.MaxValue ? $"{minG:F2}G - {maxG:F2}G" : $"{minG:F2}G+"; ScatterPlotSeries newSeries = _dataExtractor.ExtractSeries(loadedLaps, _filters, seriesTitle, ColorMap[i]); if (newSeries == null) { continue; } scatterPlot.AddScatterPlotSeries(newSeries); } scatterPlot.AddAnnotation(new LineAnnotation() { Slope = 1, Intercept = 0, Color = OxyColors.Red, StrokeThickness = 1, LineStyle = LineStyle.Solid }); ScatterPlotChartViewModel viewModel = new ScatterPlotChartViewModel() { Title = title }; viewModel.FromModel(scatterPlot); return(viewModel); }