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
AnalyticsWidgetStartDistances.xaml.cs
1using LiveChartsCore;
2using LiveChartsCore.Measure;
3using LiveChartsCore.SkiaSharpView;
4using LiveChartsCore.SkiaSharpView.Painting;
5using LiveChartsCore.Themes;
6using SkiaSharp;
8
10{
14 public partial class AnalyticsWidgetStartDistances : AnalyticsWidgetBase
15 {
17
18 public AnalyticsWidgetStartDistances(AnalyticsModuleStartDistances analyticsModule) : base(analyticsModule)
19 {
20 InitializeComponent();
21 }
22
23 public override string Icon { get; } = "\uECC6";
24
25 public override void Refresh()
26 {
27 OnPropertyChanged(nameof(StartsPerDistanceSeries));
28 base.Refresh();
29 }
30
31 public ISeries[] StartsPerDistanceSeries
32 {
33 get
34 {
35 if (_analyticsModule == null) return null;
36
37 Dictionary<ushort, double> percentageStartsPerDistance = _analyticsModule.PercentageStartsPerDistance;
38 Dictionary<ushort, int> numberStartsPerDistance = _analyticsModule.NumberStartsPerDistance;
39
40 List<ISeries> seriesList = new List<ISeries>();
41 foreach (ushort distance in percentageStartsPerDistance.Keys)
42 {
43 var series = new PieSeries<double>
44 {
45 Values = new[] { percentageStartsPerDistance[distance] },
46 Name = $"{distance}m ({numberStartsPerDistance[distance]})",
47 DataLabelsPaint = new SolidColorPaint(SKColors.Black),
48 DataLabelsSize = 14,
49 DataLabelsPosition = PolarLabelsPosition.Middle,
50 DataLabelsFormatter = point => point.Coordinate.PrimaryValue == 0 ? "" : point.Coordinate.PrimaryValue.ToString("N1") + "%",
51 Pushout = 3,
52 HoverPushout = 10,
53 Fill = new SolidColorPaint(ColorPalletes.MaterialDesign500[(int)percentageStartsPerDistance.Keys.ToList().IndexOf(distance) % ColorPalletes.MaterialDesign500.Length].AsSKColor())
54 };
55 seriesList.Add(series);
56 }
57
58 return seriesList.ToArray();
59 }
60 }
61 }
62}
Analytics module to calculate the number of starts per distance.
Dictionary< ushort, int > NumberStartsPerDistance
Number of valid starts per distance.
Dictionary< ushort, double > PercentageStartsPerDistance
Percentage of valid starts per distance.
IAnalyticsModule AnalyticsModule
Analytics module used by this user control.
AnalyticsWidgetBase(IAnalyticsModule analyticsModule)
Constructor of the AnalyticsWidgetBase