diff --git a/audit/internal/webui/server.go b/audit/internal/webui/server.go index 8f163e1..f78664b 100644 --- a/audit/internal/webui/server.go +++ b/audit/internal/webui/server.go @@ -634,6 +634,12 @@ func renderChartSVG(title string, datasets [][]float64, names []string, labels [ }} } + // Add a single peak mark line on the series that holds the global maximum. + peakIdx, peakVal := globalPeakSeries(datasets) + if peakIdx >= 0 && peakVal > 0 && peakIdx < len(opt.SeriesList) { + opt.SeriesList[peakIdx].MarkLine = gocharts.NewMarkLine(gocharts.SeriesMarkTypeMax) + } + p := gocharts.NewPainter(gocharts.PainterOptions{ OutputFormat: gocharts.ChartOutputSVG, Width: 1400, @@ -645,6 +651,21 @@ func renderChartSVG(title string, datasets [][]float64, names []string, labels [ return p.Bytes() } +// globalPeakSeries returns the index of the series containing the global maximum +// value across all datasets, and that maximum value. +func globalPeakSeries(datasets [][]float64) (idx int, peak float64) { + idx = -1 + for i, ds := range datasets { + for _, v := range ds { + if v > peak { + peak = v + idx = i + } + } + } + return idx, peak +} + func sanitizeChartText(s string) string { if s == "" { return ""