26 InitializeComponent();
27 _workspaceService = workspaceService;
28 PART_scrollViewerChart.SizeChanged += (sender, e) => OnPropertyChanged(nameof(
ChartHeight));
31 public override string Icon {
get; } =
"\uE769";
35 OnPropertyChanged(nameof(StartDistancesPerPersonSeries));
37 OnPropertyChanged(nameof(XAxes));
38 OnPropertyChanged(nameof(YAxes));
42 public Dictionary<Person, List<int>> DistancesBetweenStartsPerPersonReversed => _analyticsModule?.
DistancesBetweenStartsPerPerson?.Reverse()?.ToDictionary() ??
new Dictionary<Person, List<int>>();
44 public ISeries[] StartDistancesPerPersonSeries
52 int maxLength = DistancesBetweenStartsPerPersonReversed.Values.Max(list => list.Count);
53 List<List<int?>> normalizedLists = DistancesBetweenStartsPerPersonReversed.Values.Select(list =>
55 List<int?> padded = list.Select(i => (
int?)i).ToList();
56 while (padded.Count < maxLength) { padded.Add(
null); }
60 List<ISeries> seriesList =
new List<ISeries>();
61 for (
int i = 0; i < maxLength; i++)
63 var series =
new StackedRowSeries<int?>
67 Values = normalizedLists.Select(list => list[i]).ToList(),
68 DataLabelsPaint =
new SolidColorPaint(SKColors.Black),
70 DataLabelsPosition = DataLabelsPosition.Middle,
74 .OnPointMeasured(point =>
77 if (point.Visual is
null)
return;
78 SolidColorBrush displayColor;
79 if(point.Model.Value < shortPausesThreshold)
81 displayColor = Application.Current.Resources[
"BrushError"] as SolidColorBrush;
85 displayColor = Application.Current.Resources[
"BrushOk"] as SolidColorBrush;
87 point.Visual.Fill =
new SolidColorPaint(SKColor.Parse(displayColor.Color.ToString()));
89 (series as StackedRowSeries<int?>).Stroke.StrokeThickness = 2;
90 seriesList.Add(series);
93 return seriesList.ToArray();
106 public double ChartHeight => Math.Max(PART_scrollViewerChart.ActualHeight, DistancesBetweenStartsPerPersonReversed.Keys.Count *
ChartMaxBarWidth);
108 public Axis[] XAxes =>
114 NameTextSize = ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT,
116 SeparatorsPaint = COLORPAINT_SEPARATORS,
118 TextSize = ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT,
123 public Axis[] YAxes =>
128 SeparatorsPaint =
null,
129 Labels = DistancesBetweenStartsPerPersonReversed.Keys.Select(p => $
"{p.FirstName}, {p.Name}").ToArray(),
131 TextSize = ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT,
133 ForceStepToMin =
true