From 60b6b687513c2a9b2cccc0a51336b8b6651693ae Mon Sep 17 00:00:00 2001 From: Erik Darling <2136037+erikdarlingdata@users.noreply.github.com> Date: Thu, 12 Feb 2026 20:53:20 -0500 Subject: [PATCH] Dashboard: always show legends on Performance Trends charts (#11) Scatter series and legend are now created unconditionally so the legend displays the series name even when there's no data for the time range. Co-Authored-By: Claude Opus 4.6 --- .../Controls/QueryPerformanceContent.xaml.cs | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/Dashboard/Controls/QueryPerformanceContent.xaml.cs b/Dashboard/Controls/QueryPerformanceContent.xaml.cs index c4396979..e3dd1e8e 100644 --- a/Dashboard/Controls/QueryPerformanceContent.xaml.cs +++ b/Dashboard/Controls/QueryPerformanceContent.xaml.cs @@ -915,18 +915,13 @@ private void LoadDurationChart(WpfPlot chart, IEnumerable tre dataList.Select(d => d.CollectionTime), dataList.Select(d => d.AvgDurationMs)); - if (xs.Length > 0) - { - var scatter = chart.Plot.Add.Scatter(xs, ys); - scatter.LineWidth = 2; - scatter.MarkerSize = 5; - scatter.Color = color; - scatter.LegendText = legendText; - - _legendPanels[chart] = chart.Plot.ShowLegend(ScottPlot.Edge.Bottom); - chart.Plot.Legend.FontSize = 12; - } - else + var scatter = chart.Plot.Add.Scatter(xs, ys); + scatter.LineWidth = 2; + scatter.MarkerSize = 5; + scatter.Color = color; + scatter.LegendText = legendText; + + if (xs.Length == 0) { double xCenter = xMin + (xMax - xMin) / 2; var noDataText = chart.Plot.Add.Text("No data for selected time range", xCenter, 0.5); @@ -935,6 +930,9 @@ private void LoadDurationChart(WpfPlot chart, IEnumerable tre noDataText.LabelAlignment = ScottPlot.Alignment.MiddleCenter; } + _legendPanels[chart] = chart.Plot.ShowLegend(ScottPlot.Edge.Bottom); + chart.Plot.Legend.FontSize = 12; + chart.Plot.Axes.DateTimeTicksBottom(); chart.Plot.Axes.SetLimitsX(xMin, xMax); chart.Plot.YLabel("Duration (ms/sec)"); @@ -971,18 +969,13 @@ private void LoadExecChart(IEnumerable execTrends, int hours dataList.Select(d => d.CollectionTime), dataList.Select(d => (double)d.ExecutionsPerSecond)); - if (xs.Length > 0) - { - var scatter = QueryPerfTrendsExecChart.Plot.Add.Scatter(xs, ys); - scatter.LineWidth = 2; - scatter.MarkerSize = 5; - scatter.Color = ScottPlot.Colors.Blue; - scatter.LegendText = "Executions/sec"; + var scatter = QueryPerfTrendsExecChart.Plot.Add.Scatter(xs, ys); + scatter.LineWidth = 2; + scatter.MarkerSize = 5; + scatter.Color = ScottPlot.Colors.Blue; + scatter.LegendText = "Executions/sec"; - _legendPanels[QueryPerfTrendsExecChart] = QueryPerfTrendsExecChart.Plot.ShowLegend(ScottPlot.Edge.Bottom); - QueryPerfTrendsExecChart.Plot.Legend.FontSize = 12; - } - else + if (xs.Length == 0) { double xCenter = xMin + (xMax - xMin) / 2; var noDataText = QueryPerfTrendsExecChart.Plot.Add.Text("No data for selected time range", xCenter, 0.5); @@ -991,6 +984,9 @@ private void LoadExecChart(IEnumerable execTrends, int hours noDataText.LabelAlignment = ScottPlot.Alignment.MiddleCenter; } + _legendPanels[QueryPerfTrendsExecChart] = QueryPerfTrendsExecChart.Plot.ShowLegend(ScottPlot.Edge.Bottom); + QueryPerfTrendsExecChart.Plot.Legend.FontSize = 12; + QueryPerfTrendsExecChart.Plot.Axes.DateTimeTicksBottom(); QueryPerfTrendsExecChart.Plot.Axes.SetLimitsX(xMin, xMax); QueryPerfTrendsExecChart.Plot.YLabel("Executions/sec");