From 107d2d599c1ed078bfb071f394c89e89c55b1bd2 Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Sat, 28 Mar 2026 17:26:05 -0400 Subject: [PATCH] Fix wait stats cleanup: duplicate using, label overlap, avg label clipping - Remove duplicate `using System;` in WaitStatsProfileControl - Clamp avg line label position to prevent clipping at top of chart - Skip day boundary labels when too dense to prevent overlap on wide ranges Co-Authored-By: Claude Opus 4.6 (1M context) --- .../Controls/WaitStatsProfileControl.axaml.cs | 1 - .../Controls/WaitStatsRibbonControl.axaml.cs | 14 ++++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/PlanViewer.App/Controls/WaitStatsProfileControl.axaml.cs b/src/PlanViewer.App/Controls/WaitStatsProfileControl.axaml.cs index 1f5aa26..647b40a 100644 --- a/src/PlanViewer.App/Controls/WaitStatsProfileControl.axaml.cs +++ b/src/PlanViewer.App/Controls/WaitStatsProfileControl.axaml.cs @@ -1,5 +1,4 @@ using System; -using System; using System.Collections.Generic; using System.Linq; using Avalonia; diff --git a/src/PlanViewer.App/Controls/WaitStatsRibbonControl.axaml.cs b/src/PlanViewer.App/Controls/WaitStatsRibbonControl.axaml.cs index 5805bea..123e96e 100644 --- a/src/PlanViewer.App/Controls/WaitStatsRibbonControl.axaml.cs +++ b/src/PlanViewer.App/Controls/WaitStatsRibbonControl.axaml.cs @@ -228,7 +228,7 @@ private void Redraw() }, }; Canvas.SetLeft(avgLabel, 2); - Canvas.SetTop(avgLabel, avgY - 16); + Canvas.SetTop(avgLabel, Math.Max(0, avgY - 16)); RibbonCanvas.Children.Add(avgLabel); } } @@ -246,8 +246,18 @@ private void Redraw() if (dayIndices.Count > 0) { - foreach (var i in dayIndices) + // Skip labels when day boundaries are too dense to avoid overlap + // ~40px per label is a reasonable minimum at fontSize=8 + int labelSkip = 1; + if (dayIndices.Count > 1) { + var avgGapPx = (dayIndices[^1] - dayIndices[0]) * stepX / (dayIndices.Count - 1); + if (avgGapPx < 40) labelSkip = (int)Math.Ceiling(40.0 / avgGapPx); + } + + for (int li = 0; li < dayIndices.Count; li += labelSkip) + { + var i = dayIndices[li]; var dt = allHours[i]; var tb = new TextBlock {