diff --git a/go.mod b/go.mod index 623b7682d..610fe80c8 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/go-openapi/loads v0.22.0 github.com/go-openapi/spec v0.21.0 github.com/go-xmlfmt/xmlfmt v1.1.2 - github.com/guptarohit/asciigraph v0.7.2 + github.com/guptarohit/asciigraph v0.7.3 github.com/nbio/st v0.0.0-20140626010706-e9e8d9816f32 github.com/opentracing/opentracing-go v1.2.0 github.com/peterbourgon/diskv v2.0.1+incompatible diff --git a/go.sum b/go.sum index 7885fe45c..b1a014ab7 100644 --- a/go.sum +++ b/go.sum @@ -90,8 +90,8 @@ github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= -github.com/guptarohit/asciigraph v0.7.2 h1:pBBJYbMl4j7zS4AwmrfAs6tA0VQOEQC933aG72dlrFA= -github.com/guptarohit/asciigraph v0.7.2/go.mod h1:dYl5wwK4gNsnFf9Zp+l06rFiDZ5YtXM6x7SRWZ3KGag= +github.com/guptarohit/asciigraph v0.7.3 h1:p05XDDn7cBTWiBqWb30mrwxd6oU0claAjqeytllnsPY= +github.com/guptarohit/asciigraph v0.7.3/go.mod h1:dYl5wwK4gNsnFf9Zp+l06rFiDZ5YtXM6x7SRWZ3KGag= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542 h1:2VTzZjLZBgl62/EtslCrtky5vbi9dd7HrQPQIx6wqiw= github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542/go.mod h1:Ow0tF8D4Kplbc8s8sSb3V2oUCygFHVp8gC3Dn6U4MNI= github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f h1:7LYC+Yfkj3CTRcShK0KOL/w6iTiKyqqBA9a41Wnggw8= diff --git a/vendor/github.com/guptarohit/asciigraph/CHANGELOG.md b/vendor/github.com/guptarohit/asciigraph/CHANGELOG.md index cbe0e4744..ef3f5b447 100644 --- a/vendor/github.com/guptarohit/asciigraph/CHANGELOG.md +++ b/vendor/github.com/guptarohit/asciigraph/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. +## [0.7.3] - 2024-10-26 + +### Fixed + +- Incorrect plot height calculation for small value ranges (#59) + ## [0.7.2] - 2024-08-12 ### Fixed diff --git a/vendor/github.com/guptarohit/asciigraph/Dockerfile b/vendor/github.com/guptarohit/asciigraph/Dockerfile index 32f3ed71a..d0358ac43 100644 --- a/vendor/github.com/guptarohit/asciigraph/Dockerfile +++ b/vendor/github.com/guptarohit/asciigraph/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.17-alpine AS builder +FROM golang:1.23-alpine AS builder WORKDIR /app COPY cmd ./cmd COPY go.mod ./ diff --git a/vendor/github.com/guptarohit/asciigraph/asciigraph.go b/vendor/github.com/guptarohit/asciigraph/asciigraph.go index c0fac1545..608eb6a49 100644 --- a/vendor/github.com/guptarohit/asciigraph/asciigraph.go +++ b/vendor/github.com/guptarohit/asciigraph/asciigraph.go @@ -48,12 +48,12 @@ func PlotMany(data [][]float64, options ...Option) string { minimum, maximum := math.Inf(1), math.Inf(-1) for i := range data { - min, max := minMaxFloat64Slice(data[i]) - if min < minimum { - minimum = min + minVal, maxVal := minMaxFloat64Slice(data[i]) + if minVal < minimum { + minimum = minVal } - if max > maximum { - maximum = max + if maxVal > maximum { + maximum = maxVal } } if config.LowerBound != nil && *config.LowerBound < minimum { @@ -65,11 +65,7 @@ func PlotMany(data [][]float64, options ...Option) string { interval := math.Abs(maximum - minimum) if config.Height <= 0 { - if int(interval) <= 0 { - config.Height = int(interval * math.Pow10(int(math.Ceil(-math.Log10(interval))))) - } else { - config.Height = int(interval) - } + config.Height = calculateHeight(interval) } if config.Offset <= 0 { diff --git a/vendor/github.com/guptarohit/asciigraph/utils.go b/vendor/github.com/guptarohit/asciigraph/utils.go index 128ad2973..c1136a1fc 100644 --- a/vendor/github.com/guptarohit/asciigraph/utils.go +++ b/vendor/github.com/guptarohit/asciigraph/utils.go @@ -89,3 +89,17 @@ func init() { } } } + +func calculateHeight(interval float64) int { + if interval >= 1 { + return int(interval) + } + + scaleFactor := math.Pow(10, math.Floor(math.Log10(interval))) + scaledDelta := interval / scaleFactor + + if scaledDelta < 2 { + return int(math.Ceil(scaledDelta)) + } + return int(math.Floor(scaledDelta)) +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 07b967020..d935d137a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -237,7 +237,7 @@ github.com/google/uuid # github.com/gorilla/mux v1.8.0 ## explicit; go 1.12 github.com/gorilla/mux -# github.com/guptarohit/asciigraph v0.7.2 +# github.com/guptarohit/asciigraph v0.7.3 ## explicit; go 1.11 github.com/guptarohit/asciigraph # github.com/h2non/parth v0.0.0-20190131123155-b4df798d6542