Skip to content

Commit 353acdb

Browse files
committed
add evg ref line in waitstats chart
1 parent 4029801 commit 353acdb

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

src/PlanViewer.App/Controls/QueryStoreOverviewControl.axaml.cs

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,11 +483,15 @@ private void DrawWaitStatsChart()
483483

484484
// Find max stacked total for Y scaling
485485
double maxTotal = 0;
486+
double totalWaitSum = 0;
487+
int bucketsWithData = 0;
486488
foreach (var hour in allHours)
487489
{
488490
if (!hourLookup.TryGetValue(hour, out var items)) continue;
489491
var total = items.Sum(x => x.Total);
490492
if (total > maxTotal) maxTotal = total;
493+
totalWaitSum += total;
494+
bucketsWithData++;
491495
}
492496
if (maxTotal <= 0) maxTotal = 1;
493497

@@ -581,6 +585,43 @@ private void DrawWaitStatsChart()
581585
WaitStatsCanvas.Children.Add(tb);
582586
}
583587
}
588+
589+
// ── Horizontal dashed average line ─────────────────────────────────
590+
if (bucketsWithData > 0)
591+
{
592+
var avgWait = totalWaitSum / bucketsWithData;
593+
if (avgWait > 0 && avgWait <= maxTotal)
594+
{
595+
var avgY = paddingTop + chartH - (avgWait / maxTotal) * chartH;
596+
var dashBrush = new SolidColorBrush(Color.Parse("#E4E6EB"));
597+
var avgLine = new Line
598+
{
599+
StartPoint = new Point(0, avgY),
600+
EndPoint = new Point(w, avgY),
601+
Stroke = dashBrush,
602+
StrokeThickness = 1,
603+
StrokeDashArray = [6, 3],
604+
Opacity = 0.7,
605+
};
606+
WaitStatsCanvas.Children.Add(avgLine);
607+
608+
var avgLabel = new Border
609+
{
610+
Background = new SolidColorBrush(Color.Parse("#B0D0D0D0")),
611+
CornerRadius = new CornerRadius(3),
612+
Padding = new Thickness(4, 1),
613+
Child = new TextBlock
614+
{
615+
Text = $"avg:{WaitRatioFormatter.Format(avgWait)}",
616+
FontSize = 10,
617+
Foreground = Brushes.Black,
618+
},
619+
};
620+
Canvas.SetLeft(avgLabel, 2);
621+
Canvas.SetTop(avgLabel, Math.Max(0, avgY - 16));
622+
WaitStatsCanvas.Children.Add(avgLabel);
623+
}
624+
}
584625
}
585626

586627
// ── Bar Chart Cards ─────────────────────────────────────────────────────

0 commit comments

Comments
 (0)