sicht/auswertung.py: je Uhrzeit, Wochentag (Ortszeit Europe/Berlin, eigene EU-Sommerzeitregel), Sitzungsphase und Tischzahl jetzt Haende, bb/100 mit 95-%-Band, Spielzeit, Haende/h und Geld/h mit Band. `wann` nennt die beste und schwaechste Zelle nur unter Zellen ab 1000 Haenden; "sicher" erst, wenn die Grenze nach Bonferroni ueber alle verglichenen Zellen haelt. WinUI: Karte "Wann es am besten laeuft" mit Band-Diagramm (blass unter 1000 Haenden), Umschalter bb/100, Geld/h, Haende. Absturz behoben: die wiederverwendeten Felder (Kurve, Aufteilung, Verlauf) hingen beim Neubau noch am alten Baum (COMException bei Wechsel Uebung/Cash und neuen Haenden). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
378 lines
20 KiB
C#
378 lines
20 KiB
C#
using Microsoft.UI.Xaml;
|
|
using Microsoft.UI.Xaml.Controls;
|
|
using Microsoft.UI.Xaml.Input;
|
|
using Microsoft.UI.Xaml.Media;
|
|
using Microsoft.UI.Xaml.Shapes;
|
|
using Pokerfreak.Cockpit.Kern;
|
|
using Windows.Foundation;
|
|
|
|
namespace Pokerfreak.Cockpit.Seiten;
|
|
|
|
/// <summary>Eine Reihe eines Liniendiagramms: Name, Farbe, Punkte (x aufsteigend), Strichart.</summary>
|
|
public sealed record KurvenReihe(string Name, string Ton, IReadOnlyList<(double X, double Y)> Punkte, bool Gestrichelt = false,
|
|
bool Flaeche = false, double Dicke = 2);
|
|
|
|
/// <summary>
|
|
/// Diagramme des Statistik-Reiters: zeichnen auf einer Leinwand (Diagramm), mit Fadenkreuz und Wertfenster
|
|
/// beim Zeigen. Jede Zeichnung haelt nur wenige hundert Formen - die Datenschicht duennt die Kurven aus
|
|
/// (sicht/auswertung.KURVE_PUNKTE), so ruckelt nichts auch bei zehntausenden Haenden.
|
|
/// </summary>
|
|
public static class Diagramme
|
|
{
|
|
private static T Ort<T>(T e, double x, double y) where T : UIElement
|
|
{
|
|
Canvas.SetLeft(e, x);
|
|
Canvas.SetTop(e, y);
|
|
return e;
|
|
}
|
|
|
|
private static Border Wertfenster(IEnumerable<(string Text, string? Ton)> zeilen)
|
|
{
|
|
var s = Ui.Spalte(1);
|
|
foreach (var (text, ton) in zeilen)
|
|
{
|
|
if (ton == null) s.Children.Add(Ui.Winzig(text, Ui.Zweit, true));
|
|
else s.Children.Add(Ui.Reihe(5, Ui.Punkt(ton, 7).Mit(p => p.VerticalAlignment = VerticalAlignment.Center), Ui.Text(text, 11, zahlen: true)));
|
|
}
|
|
return new Border
|
|
{
|
|
Background = new SolidColorBrush(Windows.UI.Color.FromArgb(0xF0, 0x20, 0x22, 0x27)),
|
|
BorderBrush = Ui.Weiss(0.12),
|
|
BorderThickness = new Thickness(1),
|
|
CornerRadius = new CornerRadius(6),
|
|
Padding = new Thickness(8, 5, 8, 6),
|
|
Child = s,
|
|
IsHitTestVisible = false,
|
|
};
|
|
}
|
|
|
|
/// <summary>Das Wertfenster neben den Zeiger setzen, im Diagramm gehalten.</summary>
|
|
private static void Fenster(Canvas c, Border f, double x, double y, double b, double h)
|
|
{
|
|
f.Measure(new Size(400, 400));
|
|
var w = f.DesiredSize.Width;
|
|
var fh = f.DesiredSize.Height;
|
|
var links = x + 12 + w > b ? x - 12 - w : x + 12;
|
|
Ort(f, Math.Max(0, links), Math.Clamp(y - fh / 2, 0, Math.Max(0, h - fh)));
|
|
c.Children.Add(f);
|
|
}
|
|
|
|
/// <summary>Mehrere Linien auf gemeinsamer Achse, Fadenkreuz mit allen Werten an der Stelle.</summary>
|
|
public static UIElement Kurven(IReadOnlyList<KurvenReihe> reihen, Func<double, string> xText, Func<double, string> yText,
|
|
Func<double, string?>? xKopf = null, double hoehe = 260)
|
|
{
|
|
var mit = reihen.Where(r => r.Punkte.Count > 0).ToList();
|
|
if (mit.Count == 0) return Ui.Klein("Noch keine Punkte.");
|
|
double x0 = mit.Min(r => r.Punkte[0].X), x1 = mit.Max(r => r.Punkte[^1].X);
|
|
if (x1 - x0 < 1e-9) x1 = x0 + 1;
|
|
double lo = Math.Min(0, mit.Min(r => r.Punkte.Min(p => p.Y))), hi = Math.Max(0, mit.Max(r => r.Punkte.Max(p => p.Y)));
|
|
var spiel = (hi - lo) * 0.06;
|
|
lo -= lo < 0 ? spiel : 0;
|
|
hi += spiel;
|
|
var d = new Diagramm(hoehe);
|
|
Func<double, double> Y = v => v;
|
|
double X(double v, double b) => Diagramm.Links + 4 + (b - Diagramm.Links - 8) * (v - x0) / (x1 - x0);
|
|
d.Zeichnen = (c, b, h) =>
|
|
{
|
|
Y = Diagramm.AchseY(c, b, h, lo, hi);
|
|
foreach (var r in mit)
|
|
{
|
|
if (r.Flaeche)
|
|
{
|
|
var f = new Polygon { Fill = Ui.Pinsel(r.Ton, 0.10) };
|
|
var basis = Y(Math.Clamp(0, lo, hi));
|
|
f.Points.Add(new Point(X(r.Punkte[0].X, b), basis));
|
|
foreach (var p in r.Punkte) f.Points.Add(new Point(X(p.X, b), Y(p.Y)));
|
|
f.Points.Add(new Point(X(r.Punkte[^1].X, b), basis));
|
|
c.Children.Add(f);
|
|
}
|
|
var linie = new Polyline { Stroke = Ui.Pinsel(r.Ton, r.Gestrichelt ? 0.9 : 1), StrokeThickness = r.Dicke, StrokeLineJoin = PenLineJoin.Round };
|
|
if (r.Gestrichelt) linie.StrokeDashArray = new DoubleCollection { 3, 2 };
|
|
foreach (var p in r.Punkte) linie.Points.Add(new Point(X(p.X, b), Y(p.Y)));
|
|
c.Children.Add(linie);
|
|
}
|
|
for (var i = 0; i <= 3; i++)
|
|
{
|
|
var xv = x0 + (x1 - x0) * i / 3;
|
|
Diagramm.Beschriftung(c, xText(xv), Math.Clamp(X(xv, b), Diagramm.Links + 30, b - 34), h - Diagramm.Unten + 3, 70);
|
|
}
|
|
};
|
|
d.Zeiger = (c, b, h, pos) =>
|
|
{
|
|
var xv = x0 + (pos.X - Diagramm.Links - 4) / Math.Max(1, b - Diagramm.Links - 8) * (x1 - x0);
|
|
if (xv < x0 || xv > x1) return;
|
|
var px = X(xv, b);
|
|
c.Children.Add(new Line { X1 = px, X2 = px, Y1 = 4, Y2 = h - Diagramm.Unten, Stroke = Ui.Weiss(0.35), StrokeThickness = 1 });
|
|
var zeilen = new List<(string, string?)> { (xKopf?.Invoke(xv) ?? xText(xv), null) };
|
|
foreach (var r in mit)
|
|
{
|
|
var p = Naechster(r.Punkte, xv);
|
|
zeilen.Add(($"{r.Name} {yText(p.Y)}", r.Ton));
|
|
c.Children.Add(Ort(new Ellipse { Width = 7, Height = 7, Fill = Ui.Pinsel(r.Ton), Stroke = Ui.Schwarz(0.6), StrokeThickness = 1 },
|
|
X(p.X, b) - 3.5, Y(p.Y) - 3.5));
|
|
}
|
|
Fenster(c, Wertfenster(zeilen), px, pos.Y, b, h);
|
|
};
|
|
var legende = new VariableSizedWrapGrid { Orientation = Orientation.Horizontal, ItemHeight = 18, ItemWidth = 150 };
|
|
foreach (var r in mit)
|
|
{
|
|
var strich = new Line { X1 = 0, X2 = 16, Y1 = 6, Y2 = 6, Stroke = Ui.Pinsel(r.Ton), StrokeThickness = 2.4, VerticalAlignment = VerticalAlignment.Center };
|
|
if (r.Gestrichelt) strich.StrokeDashArray = new DoubleCollection { 2, 1.5 };
|
|
legende.Children.Add(Ui.Reihe(5, new Canvas { Width = 16, Height = 12, Children = { strich } }, Ui.Winzig(r.Name)));
|
|
}
|
|
return Ui.Spalte(6, d, legende);
|
|
}
|
|
|
|
private static (double X, double Y) Naechster(IReadOnlyList<(double X, double Y)> p, double x)
|
|
{
|
|
int lo = 0, hi = p.Count - 1;
|
|
while (hi - lo > 1)
|
|
{
|
|
var m = (lo + hi) / 2;
|
|
if (p[m].X < x) lo = m; else hi = m;
|
|
}
|
|
return Math.Abs(p[lo].X - x) <= Math.Abs(p[hi].X - x) ? p[lo] : p[hi];
|
|
}
|
|
|
|
/// <summary>Eine Zeile eines Spannen-Diagramms (bb/100 mit 95 %).</summary>
|
|
public sealed record Spanne(string Name, string Unter, double? Wert, double? Unten, double? Oben, string Rechts, double Haende = 1000);
|
|
|
|
/// <summary>Unter so vielen Haenden bestimmt eine Zeile die Achse nicht (sie wird blass und am Rand gehalten).</summary>
|
|
public const double SpanneMinHaende = 30;
|
|
|
|
/// <summary>bb/100 mit 95-%-Spanne je Zeile auf gemeinsamer Achse; Null als Strich.</summary>
|
|
public static UIElement Spannen(IReadOnlyList<Spanne> zeilen, string einheit = "bb/100")
|
|
{
|
|
if (zeilen.Count == 0) return Ui.Klein("Noch keine Hände in dieser Aufteilung.");
|
|
var tragend = zeilen.Where(z => z.Haende >= SpanneMinHaende).ToList();
|
|
var werte = (tragend.Count > 0 ? tragend : zeilen).SelectMany(z => new[] { z.Unten, z.Oben, z.Wert }).OfType<double>().Append(0.0).ToList();
|
|
double lo = werte.Min(), hi = werte.Max();
|
|
if (hi - lo < 1e-9) { lo -= 1; hi += 1; }
|
|
var rand = (hi - lo) * 0.04;
|
|
lo -= rand;
|
|
hi += rand;
|
|
var s = Ui.Spalte(7);
|
|
var achse = new Diagramm(14)
|
|
{
|
|
Zeichnen = (c, br, _) =>
|
|
{
|
|
foreach (var v in new[] { lo + rand, 0.0, hi - rand })
|
|
{
|
|
var x = br * (v - lo) / (hi - lo);
|
|
Diagramm.Beschriftung(c, Format.Kurzzahl(v), Math.Clamp(x, 24, br - 24), 0, 48);
|
|
}
|
|
},
|
|
};
|
|
foreach (var z in zeilen)
|
|
{
|
|
var ton = Teile.Ton(z.Wert) ?? "grau";
|
|
var blass = z.Haende < SpanneMinHaende && tragend.Count > 0;
|
|
var kopf = new Grid { ColumnSpacing = 6 };
|
|
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
|
kopf.ColumnDefinitions.Add(new ColumnDefinition());
|
|
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
|
kopf.Children.Add(Ui.Text(z.Name, 12, fett: true));
|
|
kopf.Children.Add(Ui.Winzig(z.Unter, Ui.Dritt).Spalte(1).Mit(t => t.VerticalAlignment = VerticalAlignment.Center));
|
|
kopf.Children.Add(Ui.Text(z.Rechts, 12, Teile.Ton(z.Wert), fett: true, zahlen: true).Spalte(2));
|
|
var balken = new Diagramm(12)
|
|
{
|
|
Zeichnen = (c, br, _) =>
|
|
{
|
|
double X(double v) => Math.Clamp(br * (v - lo) / (hi - lo), 0, br);
|
|
c.Opacity = blass ? 0.45 : 1;
|
|
c.Children.Add(Ort(new Rectangle { Width = br, Height = 4, RadiusX = 2, RadiusY = 2, Fill = Ui.Weiss(0.07) }, 0, 4));
|
|
c.Children.Add(Ort(new Rectangle { Width = 1, Height = 12, Fill = Ui.Weiss(0.4) }, X(0), 0));
|
|
if (z.Unten is double un && z.Oben is double ob)
|
|
c.Children.Add(Ort(new Rectangle { Width = Math.Max(2, X(ob) - X(un)), Height = 8, RadiusX = 4, RadiusY = 4, Fill = Ui.Pinsel(ton, 0.35) }, X(un), 2));
|
|
if (z.Wert is double bv)
|
|
c.Children.Add(Ort(new Ellipse { Width = 9, Height = 9, Fill = Ui.Pinsel(ton) }, Math.Clamp(X(bv) - 4.5, 0, br - 9), 1.5));
|
|
},
|
|
};
|
|
if (blass) kopf.Opacity = 0.6;
|
|
ToolTipService.SetToolTip(balken, blass ? "unter 30 Händen: noch kein Urteil" : z.Unten is double uu && z.Oben is double oo
|
|
? $"{Format.Vorzeichen(z.Wert)} {einheit}, 95 %: {Format.Vorzeichen(uu)} bis {Format.Vorzeichen(oo)}"
|
|
: "zu wenig Hände für eine Spanne");
|
|
s.Children.Add(Ui.Spalte(3, kopf, balken));
|
|
}
|
|
s.Children.Add(achse);
|
|
return s;
|
|
}
|
|
|
|
/// <summary>Eine Zelle eines Band-Diagramms: Wert mit 95-%-Band, Stichprobe, Fenstertext; Hervor = umrandet.</summary>
|
|
public sealed record Zelle(string Name, double? Wert, double? Unten, double? Oben, double Haende, string[] Fenster, bool Hervor = false);
|
|
|
|
/// <summary>Senkrechte Baender nebeneinander (je Stunde, Tag, ...): Balken = 95 %, Punkt = Wert. Zellen unter
|
|
/// `minHaende` sind blass und bestimmen die Achse nicht, damit duenne Zellen nicht glaenzen.</summary>
|
|
public static UIElement Baender(IReadOnlyList<Zelle> zellen, double minHaende, double hoehe = 220)
|
|
{
|
|
if (zellen.Count == 0) return Ui.Klein("Noch keine Werte.");
|
|
var tragend = zellen.Where(z => z.Haende >= minHaende).ToList();
|
|
if (tragend.Count == 0) tragend = zellen.Where(z => z.Haende >= SpanneMinHaende).ToList();
|
|
if (tragend.Count == 0) tragend = zellen.ToList();
|
|
var werte = tragend.SelectMany(z => new[] { z.Unten, z.Oben, z.Wert }).OfType<double>().Append(0.0).ToList();
|
|
double lo = werte.Min(), hi = werte.Max();
|
|
if (hi - lo < 1e-9) { lo -= 1; hi += 1; }
|
|
var jede = Math.Max(1, (int)Math.Ceiling(zellen.Count / 12.0));
|
|
Func<double, double> Y = v => v;
|
|
var d = new Diagramm(hoehe);
|
|
double Breite(double b) => (b - Diagramm.Links - 4) / zellen.Count;
|
|
bool Blass(Zelle z) => z.Haende < minHaende;
|
|
d.Zeichnen = (c, b, h) =>
|
|
{
|
|
Y = Diagramm.AchseY(c, b, h, lo, hi);
|
|
double Yk(double v) => Math.Clamp(Y(v), 2, h - Diagramm.Unten - 2);
|
|
var br = Breite(b);
|
|
var w = Math.Max(3, Math.Min(18, br * 0.55));
|
|
for (var i = 0; i < zellen.Count; i++)
|
|
{
|
|
var z = zellen[i];
|
|
var mitte = Diagramm.Links + 4 + i * br + br / 2;
|
|
var ton = Teile.Ton(z.Wert) ?? "grau";
|
|
var op = Blass(z) ? 0.3 : 1.0;
|
|
if (z.Hervor)
|
|
c.Children.Add(Ort(new Rectangle { Width = br - 2, Height = h - Diagramm.Unten - 4, RadiusX = 4, RadiusY = 4, Fill = Ui.Pinsel(ton, 0.08) }, mitte - br / 2 + 1, 2));
|
|
if (z.Unten is double u && z.Oben is double o)
|
|
{
|
|
var y1 = Yk(o);
|
|
var y2 = Yk(u);
|
|
c.Children.Add(Ort(new Rectangle { Width = w, Height = Math.Max(2, y2 - y1), RadiusX = w / 2, RadiusY = Math.Min(w / 2, 6), Fill = Ui.Pinsel(ton, 0.32 * op) }, mitte - w / 2, y1));
|
|
}
|
|
if (z.Wert is double v)
|
|
{
|
|
var p = Math.Min(9, w);
|
|
c.Children.Add(Ort(new Ellipse { Width = p, Height = p, Fill = Ui.Pinsel(ton, op) }, mitte - p / 2, Yk(v) - p / 2));
|
|
}
|
|
if (i % jede == 0) Diagramm.Beschriftung(c, z.Name, mitte, h - Diagramm.Unten + 3, Math.Max(br * jede, 30));
|
|
}
|
|
};
|
|
d.Zeiger = (c, b, h, pos) =>
|
|
{
|
|
var br = Breite(b);
|
|
var i = (int)Math.Floor((pos.X - Diagramm.Links - 4) / br);
|
|
if (i < 0 || i >= zellen.Count) return;
|
|
var x = Diagramm.Links + 4 + i * br;
|
|
c.Children.Add(Ort(new Rectangle { Width = br, Height = h - Diagramm.Unten - 4, Fill = Ui.Weiss(0.06) }, x, 4));
|
|
var z = zellen[i];
|
|
var ton = Teile.Ton(z.Wert) ?? "grau";
|
|
var fenster = z.Fenster.Select((t, k) => (t, k == 1 ? (string?)ton : null));
|
|
if (Blass(z)) fenster = fenster.Append(($"unter {minHaende:0} Händen: kein Urteil", (string?)null));
|
|
Fenster(c, Wertfenster(fenster), x + br / 2, pos.Y, b, h);
|
|
};
|
|
return d;
|
|
}
|
|
|
|
/// <summary>Eine Saeule mit Vorzeichen (gruen ueber, rot unter null) und Wertfenster beim Zeigen.</summary>
|
|
public sealed record Saeule(string Name, double Wert, string[] Fenster, string? Ton = null);
|
|
|
|
public static UIElement PlusMinus(IReadOnlyList<Saeule> saeulen, double hoehe = 200, Func<double, string>? yText = null)
|
|
{
|
|
if (saeulen.Count == 0) return Ui.Klein("Noch keine Werte.");
|
|
double lo = Math.Min(0, saeulen.Min(s => s.Wert)), hi = Math.Max(0, saeulen.Max(s => s.Wert));
|
|
if (hi - lo < 1e-9) hi = lo + 1;
|
|
var jede = Math.Max(1, (int)Math.Ceiling(saeulen.Count / 12.0));
|
|
Func<double, double> Y = v => v;
|
|
var d = new Diagramm(hoehe);
|
|
double Breite(double b) => (b - Diagramm.Links - 4) / saeulen.Count;
|
|
d.Zeichnen = (c, b, h) =>
|
|
{
|
|
Y = Diagramm.AchseY(c, b, h, lo, hi);
|
|
var br = Breite(b);
|
|
for (var i = 0; i < saeulen.Count; i++)
|
|
{
|
|
var s = saeulen[i];
|
|
var x = Diagramm.Links + 4 + i * br;
|
|
var oben = Y(Math.Max(0, s.Wert));
|
|
var r = new Rectangle
|
|
{
|
|
Width = Math.Max(1, br - Math.Min(4, br * 0.25)),
|
|
Height = Math.Max(1, Math.Abs(Y(0) - Y(s.Wert))),
|
|
Fill = Ui.Pinsel(s.Ton ?? (s.Wert >= 0 ? "gruen" : "rot"), 0.75),
|
|
RadiusX = 2, RadiusY = 2,
|
|
};
|
|
c.Children.Add(Ort(r, x + 1, oben));
|
|
if (i % jede == 0) Diagramm.Beschriftung(c, s.Name, x + br / 2, h - Diagramm.Unten + 3, Math.Max(br * jede, 30));
|
|
}
|
|
};
|
|
d.Zeiger = (c, b, h, pos) =>
|
|
{
|
|
var br = Breite(b);
|
|
var i = (int)Math.Floor((pos.X - Diagramm.Links - 4) / br);
|
|
if (i < 0 || i >= saeulen.Count) return;
|
|
var x = Diagramm.Links + 4 + i * br;
|
|
c.Children.Add(Ort(new Rectangle { Width = br, Height = h - Diagramm.Unten - 4, Fill = Ui.Weiss(0.06) }, x, 4));
|
|
var s = saeulen[i];
|
|
Fenster(c, Wertfenster(s.Fenster.Select((t, k) => (t, k == 0 ? null : (string?)(s.Ton ?? (s.Wert >= 0 ? "gruen" : "rot"))))), x + br / 2, pos.Y, b, h);
|
|
};
|
|
return d;
|
|
}
|
|
|
|
/// <summary>Gestapelter Anteilsbalken mit Legende (z. B. Gegnertypen).</summary>
|
|
public static UIElement Anteile(IReadOnlyList<(string Name, double Anteil, string Ton, string Zusatz)> teile)
|
|
{
|
|
var summe = teile.Sum(t => t.Anteil);
|
|
var balken = new Grid { Height = 14, CornerRadius = new CornerRadius(7) };
|
|
var i = 0;
|
|
foreach (var t in teile.Where(t => t.Anteil > 0))
|
|
{
|
|
balken.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(t.Anteil / Math.Max(1e-9, summe), GridUnitType.Star) });
|
|
var r = new Border { Background = Ui.Pinsel(t.Ton, 0.85) };
|
|
ToolTipService.SetToolTip(r, $"{t.Name}: {Format.Prozent(t.Anteil / Math.Max(1e-9, summe))} · {t.Zusatz}");
|
|
balken.Children.Add(r.Spalte(i++));
|
|
}
|
|
var legende = new VariableSizedWrapGrid { Orientation = Orientation.Horizontal, ItemHeight = 18, ItemWidth = 170 };
|
|
foreach (var t in teile)
|
|
legende.Children.Add(Ui.Reihe(5, Ui.Punkt(t.Ton, 8).Mit(p => p.VerticalAlignment = VerticalAlignment.Center),
|
|
Ui.Winzig($"{t.Name} {Format.Prozent(t.Anteil / Math.Max(1e-9, summe))}")));
|
|
return Ui.Spalte(8, balken, legende);
|
|
}
|
|
|
|
/// <summary>Streudiagramm 0..max auf beiden Achsen (VPIP gegen PFR), dazu markierte Punkte.</summary>
|
|
public static UIElement Streu(IReadOnlyList<(double X, double Y, double Groesse, string Ton, string Text)> punkte,
|
|
IReadOnlyList<(double X, double Y, string Ton, string Text)> marken,
|
|
string xName, string yName, double max = 0.8, double hoehe = 240)
|
|
{
|
|
var d = new Diagramm(hoehe);
|
|
double X(double v, double b) => Diagramm.Links + 4 + (b - Diagramm.Links - 12) * Math.Clamp(v / max, 0, 1);
|
|
Func<double, double> Y = v => v;
|
|
d.Zeichnen = (c, b, h) =>
|
|
{
|
|
Y = Diagramm.AchseY(c, b, h, 0, max);
|
|
for (var i = 0; i <= 4; i++)
|
|
Diagramm.Beschriftung(c, Format.Prozent(max * i / 4), X(max * i / 4, b), h - Diagramm.Unten + 3, 44);
|
|
c.Children.Add(new Line { X1 = X(0, b), Y1 = Y(0), X2 = X(max, b), Y2 = Y(max), Stroke = Ui.Weiss(0.10), StrokeThickness = 1, StrokeDashArray = new DoubleCollection { 3, 3 } });
|
|
foreach (var p in punkte)
|
|
{
|
|
var g = 4 + 6 * Math.Sqrt(Math.Clamp(p.Groesse, 0, 1));
|
|
var e = new Ellipse { Width = g, Height = g, Fill = Ui.Pinsel(p.Ton, 0.55), Stroke = Ui.Pinsel(p.Ton), StrokeThickness = 0.6 };
|
|
c.Children.Add(Ort(e, X(p.X, b) - g / 2, Y(p.Y) - g / 2));
|
|
}
|
|
foreach (var m in marken)
|
|
{
|
|
var r = new Rectangle { Width = 11, Height = 11, Fill = Ui.Pinsel(m.Ton), Stroke = Ui.Schwarz(0.8), StrokeThickness = 1.2, RenderTransformOrigin = new Point(0.5, 0.5), RenderTransform = new RotateTransform { Angle = 45 } };
|
|
c.Children.Add(Ort(r, X(m.X, b) - 5.5, Y(m.Y) - 5.5));
|
|
if (m.Text.Length > 0) c.Children.Add(Ort(Ui.Text(m.Text, 11, m.Ton, fett: true), X(m.X, b) + 9, Y(m.Y) - 8));
|
|
}
|
|
var xn = Ui.Winzig(xName, Ui.Dritt);
|
|
c.Children.Add(Ort(xn, b - 60, h - Diagramm.Unten - 16));
|
|
var yn = Ui.Winzig(yName, Ui.Dritt);
|
|
c.Children.Add(Ort(yn, Diagramm.Links + 6, 4));
|
|
};
|
|
d.Zeiger = (c, b, h, pos) =>
|
|
{
|
|
(double X, double Y, double Groesse, string Ton, string Text)? best = null;
|
|
var bd = 144.0;
|
|
foreach (var p in punkte)
|
|
{
|
|
var dx = X(p.X, b) - pos.X;
|
|
var dy = Y(p.Y) - pos.Y;
|
|
if (dx * dx + dy * dy < bd) { bd = dx * dx + dy * dy; best = p; }
|
|
}
|
|
if (best is not { } q) return;
|
|
c.Children.Add(Ort(new Ellipse { Width = 14, Height = 14, Stroke = Ui.Weiss(0.8), StrokeThickness = 1.5 }, X(q.X, b) - 7, Y(q.Y) - 7));
|
|
Fenster(c, Wertfenster(new (string, string?)[] { (q.Text, null), ($"{xName} {Format.Prozent(q.X)} · {yName} {Format.Prozent(q.Y)}", q.Ton) }),
|
|
X(q.X, b), Y(q.Y), b, h);
|
|
};
|
|
return d;
|
|
}
|
|
}
|