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
AnalyticsWidgetPlacesAgeDistribution.xaml.cs
1using System.Drawing;
2using LiveChartsCore;
3using LiveChartsCore.Kernel;
4using LiveChartsCore.SkiaSharpView;
5using LiveChartsCore.SkiaSharpView.Painting;
6using LiveChartsCore.SkiaSharpView.Painting.Effects;
8
10{
14 public partial class AnalyticsWidgetPlacesAgeDistribution : AnalyticsWidgetBase
15 {
17
18 public AnalyticsWidgetPlacesAgeDistribution(AnalyticsModulePlacesAgeDistribution analyticsModule) : base(analyticsModule)
19 {
20 InitializeComponent();
21 }
22
23 public override string Icon => "\uE9F9";
24
25 public override void Refresh()
26 {
27 OnPropertyChanged(nameof(BirthYearsPerResultPlaceSeries));
28 OnPropertyChanged(nameof(XAxes));
29 OnPropertyChanged(nameof(YAxes));
30 base.Refresh();
31 }
32
34
35 static float regressionLineStrokeThickness = 4;
36 static float[] regressionLineStrokeDashArray = new float[] { 3 * regressionLineStrokeThickness, 2 * regressionLineStrokeThickness };
37 static DashEffect regressionLineStrokeEffect = new DashEffect(regressionLineStrokeDashArray);
38
39 public ISeries[] BirthYearsPerResultPlaceSeries => _analyticsModule == null ? null : new ISeries[]
40 {
42 {
43 Values = BirthYearsPerResultPlace,
44 Mapping = (model, index) =>
45 {
46 return new Coordinate(model.ResultPlace, model.BirthYear);
47 },
48 YToolTipLabelFormatter = point => $"{point.Model.ResultPlace}: {point.Model.BirthYear}{Environment.NewLine}{point.Model.PersonObj.FirstName}, {point.Model.PersonObj.Name}",
49 Stroke = new SolidColorPaint(ColorPaintMahAppsAccent.Color, 4),
50 GeometryStroke = new SolidColorPaint(ColorPaintMahAppsAccent.Color, 4),
51 Fill = new SolidColorPaint(ColorPaintMahAppsAccent.Color.WithAlpha(0x33)) // modify alpha channel for transparency
52 },
53 // Linear Regression Line
54 new LineSeries<PointF>
55 {
56 Values = _analyticsModule.LinearRegressionLinePoints,
57 Mapping = (model, index) =>
58 {
59 return new Coordinate(model.X, model.Y);
60 },
61 YToolTipLabelFormatter = point => point.Model.Y.ToString("F2"),
62 Stroke = new SolidColorPaint(ColorPaintMahAppsText.Color)
63 {
64 StrokeCap = SkiaSharp.SKStrokeCap.Round,
65 StrokeThickness = regressionLineStrokeThickness,
66 PathEffect = regressionLineStrokeEffect
67 },
68 GeometrySize = 0,
69 Fill = null
70 }
71 };
72
73 public Axis[] XAxes =>
74 [
75 new Axis
76 {
77 IsVisible = true,
78 Name = Properties.Resources.ResultPlaceString,
79 NamePaint = ColorPaintMahAppsText,
80 NameTextSize = ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT,
81 LabelsPaint = ColorPaintMahAppsText,
82 TextSize = ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT,
83 MinStep = 1,
84 MinLimit = 0.5
85 }
86 ];
87
88 public Axis[] YAxes =>
89 [
90 new Axis
91 {
92 IsVisible = true,
93 Name = Properties.Resources.BirthYearString,
94 NamePaint = ColorPaintMahAppsText,
95 NameTextSize = ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT,
96 SeparatorsPaint = COLORPAINT_SEPARATORS,
97 LabelsPaint = ColorPaintMahAppsText,
98 TextSize = ANALYTICS_WIDGET_AXIS_TEXTSIZE_DEFAULT,
99 LabelsDensity = 0,
100 MinStep = 1
101 }
102 ];
103 }
104}
Analytics module to calculate the age distribution over the result places.
List< PointF > LinearRegressionLinePoints
List with the start and end points of a linear regression line through the BirthYearsPerResultPlace p...
List< ModelPlacesAgeDistribution > BirthYearsPerResultPlace
List with ModelPlacesAgeDistribution ordered by the result place.
SolidColorPaint ColorPaintMahAppsAccent
SolidColorPaint that represents the MahApps.Brushes.Accent brush.
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