Vereinsmeisterschaften  22aa7800eae54b428d40e835886cefe1fdefdfdf
This is a software that can be used to manage the internal competition of the swimming club Illertissen called "Vereinsmeisterschaften".
Loading...
Searching...
No Matches
AnalyticsWidgetStartsPerPerson.xaml.cs
1using LiveChartsCore;
2using LiveChartsCore.Kernel;
3using LiveChartsCore.Kernel.Events;
4using LiveChartsCore.Measure;
5using LiveChartsCore.SkiaSharpView;
6using LiveChartsCore.SkiaSharpView.Painting;
7using LiveChartsCore.Themes;
8using SkiaSharp;
11
13{
17 public partial class AnalyticsWidgetStartsPerPerson : AnalyticsWidgetBase
18 {
20
21 public AnalyticsWidgetStartsPerPerson(AnalyticsModuleStartsPerPerson analyticsModule) : base(analyticsModule)
22 {
23 InitializeComponent();
24 PART_scrollViewerChart.SizeChanged += (sender, e) => OnPropertyChanged(nameof(ChartHeight));
25 }
26
27 public override string Icon { get; } = "\uE77B";
28
29 public override void Refresh()
30 {
31 OnPropertyChanged(nameof(StartsPerPersonSeries));
32 OnPropertyChanged(nameof(ChartHeight));
33 OnPropertyChanged(nameof(XAxes));
34 OnPropertyChanged(nameof(YAxes));
35 base.Refresh();
36 }
37
38 public Dictionary<Person, int> NumberStartsPerPersonReordered => _analyticsModule?.NumberStartsPerPerson?.OrderBy(s => s.Value)?.ToDictionary() ?? new Dictionary<Person, int>();
39
40 public ISeries[] StartsPerPersonSeries
41 {
42 get
43 {
44 if (_analyticsModule == null) return null;
45
46 List<ISeries> seriesList = new List<ISeries>();
47 var series = new RowSeries<KeyValuePair<Person, int>>
48 {
49 Values = NumberStartsPerPersonReordered,
50 Mapping = (model, index) =>
51 {
52 return new Coordinate(index, model.Value);
53 },
54 DataLabelsPaint = new SolidColorPaint(SKColors.Black),
55 DataLabelsSize = 14,
56 DataLabelsPosition = DataLabelsPosition.End,
57 DataLabelsTranslate = new(-1, 0),
58 MaxBarWidth = ChartMaxBarWidth
59 }
60 .OnPointMeasured(point =>
61 {
62 // assign a different color to each point
63 if (point.Visual is null) return;
64 int colorIndex = point.Index;
65 point.Visual.Fill = new SolidColorPaint(ColorPalletes.MaterialDesign500[colorIndex % ColorPalletes.MaterialDesign500.Length].AsSKColor());
66 });
67 seriesList.Add(series);
68
69 return seriesList.ToArray();
70 }
71 }
72
76 public double ChartMaxBarWidth => 45;
77
82 public double ChartHeight => Math.Max(PART_scrollViewerChart.ActualHeight, NumberStartsPerPersonReordered.Keys.Count * ChartMaxBarWidth);
83
84 public Axis[] XAxes =>
85 [
86 new Axis
87 {
89 NamePaint = ColorPaintMahAppsText,
90 NameTextSize = ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT,
91 MinLimit = 0,
92 SeparatorsPaint = COLORPAINT_SEPARATORS,
93 LabelsPaint = ColorPaintMahAppsText,
94 TextSize = ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT,
95 MinStep = 1,
96 ForceStepToMin = true
97 }
98 ];
99
100 public Axis[] YAxes =>
101 [
102 new Axis
103 {
104 IsVisible = true,
105 SeparatorsPaint = null,
106 Labels = NumberStartsPerPersonReordered.Keys.Select(p => $"{p.FirstName}, {p.Name}").ToArray(),
107 LabelsPaint = ColorPaintMahAppsText,
108 TextSize = ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT,
109 MinStep = 1,
110 ForceStepToMin = true
111 }
112 ];
113 }
114}
Analytics module to calculate the number of starts per persons.
Dictionary< Person, int > NumberStartsPerPerson
Number of starts (value) per person (key).
Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
static string CountString
Sucht eine lokalisierte Zeichenfolge, die Count ähnelt.
IAnalyticsModule AnalyticsModule
Analytics module used by this user control.
SolidColorPaint ColorPaintMahAppsText
SolidColorPaint that represents the MahApps.Brushes.Text brush.
AnalyticsWidgetBase(IAnalyticsModule analyticsModule)
Constructor of the AnalyticsWidgetBase
double ChartHeight
Calculate the chart height manually to support scrolling of the RowSeries by the surrounding scroll v...