mirror of
https://github.com/jesseduffield/lazydocker.git
synced 2026-07-25 08:31:03 +00:00
Constrain asciigraph dependency to revision
Turns out if you don't constrain a dependency to a revision, it picks the latest version (which I'm guessing corresponds to a git tag) This means if you're using a fork for the sake of an extra commit that you want, you need to point at that revision (or perhaps just specify branch="master") Otherwise we'll end up pointing at an older commit
This commit is contained in:
parent
ccca53914d
commit
ad9b62e95e
4 changed files with 45 additions and 13 deletions
5
Gopkg.lock
generated
5
Gopkg.lock
generated
|
|
@ -58,12 +58,11 @@
|
||||||
revision = "9fd32a8b3d3d3f9d43c341bfe098430e07609480"
|
revision = "9fd32a8b3d3d3f9d43c341bfe098430e07609480"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:a3b08eb3ec49caec29db596d8f2aae79614413a8d2068d5082b92fa23b5b6d80"
|
digest = "1:8abef4b9ca2f94e008688685bf8fb7bb27e5c82b353a82ef9276a27b4a6d2020"
|
||||||
name = "github.com/carlosms/asciigraph"
|
name = "github.com/carlosms/asciigraph"
|
||||||
packages = ["."]
|
packages = ["."]
|
||||||
pruneopts = "NUT"
|
pruneopts = "NUT"
|
||||||
revision = "b8c6bd8cace5d89062a57acb2012b0be08fb9525"
|
revision = "22e3e1b9e3cd5ab4f79619cd65987f426d2d3dc4"
|
||||||
version = "v0.4.1"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,6 @@
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "github.com/spkg/bom"
|
name = "github.com/spkg/bom"
|
||||||
|
|
||||||
# [[constraint]]
|
[[constraint]]
|
||||||
# name = "github.com/docker/docker"
|
name = "github.com/carlosms/asciigraph"
|
||||||
# version = "v17"
|
revision = "22e3e1b9e3cd5ab4f79619cd65987f426d2d3dc4"
|
||||||
|
|
|
||||||
34
vendor/github.com/carlosms/asciigraph/asciigraph.go
generated
vendored
34
vendor/github.com/carlosms/asciigraph/asciigraph.go
generated
vendored
|
|
@ -9,6 +9,7 @@ import (
|
||||||
|
|
||||||
// Plot returns ascii graph for a series.
|
// Plot returns ascii graph for a series.
|
||||||
func Plot(series []float64, options ...Option) string {
|
func Plot(series []float64, options ...Option) string {
|
||||||
|
var logMaximum float64
|
||||||
config := configure(config{
|
config := configure(config{
|
||||||
Offset: 3,
|
Offset: 3,
|
||||||
}, options)
|
}, options)
|
||||||
|
|
@ -18,6 +19,13 @@ func Plot(series []float64, options ...Option) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
minimum, maximum := minMaxFloat64Slice(series)
|
minimum, maximum := minMaxFloat64Slice(series)
|
||||||
|
if config.Min != nil && *config.Min < minimum {
|
||||||
|
minimum = *config.Min
|
||||||
|
}
|
||||||
|
if config.Max != nil && *config.Max > maximum {
|
||||||
|
maximum = *config.Max
|
||||||
|
}
|
||||||
|
|
||||||
interval := math.Abs(maximum - minimum)
|
interval := math.Abs(maximum - minimum)
|
||||||
|
|
||||||
if config.Height <= 0 {
|
if config.Height <= 0 {
|
||||||
|
|
@ -32,7 +40,12 @@ func Plot(series []float64, options ...Option) string {
|
||||||
config.Offset = 3
|
config.Offset = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
ratio := float64(config.Height) / interval
|
var ratio float64
|
||||||
|
if interval != 0 {
|
||||||
|
ratio = float64(config.Height) / interval
|
||||||
|
} else {
|
||||||
|
ratio = 1
|
||||||
|
}
|
||||||
min2 := round(minimum * ratio)
|
min2 := round(minimum * ratio)
|
||||||
max2 := round(maximum * ratio)
|
max2 := round(maximum * ratio)
|
||||||
|
|
||||||
|
|
@ -54,7 +67,10 @@ func Plot(series []float64, options ...Option) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
precision := 2
|
precision := 2
|
||||||
logMaximum := math.Log10(math.Max(math.Abs(maximum), math.Abs(minimum))) //to find number of zeros after decimal
|
logMaximum = math.Log10(math.Max(math.Abs(maximum), math.Abs(minimum))) //to find number of zeros after decimal
|
||||||
|
if minimum == float64(0) && maximum == float64(0) {
|
||||||
|
logMaximum = float64(-1)
|
||||||
|
}
|
||||||
|
|
||||||
if logMaximum < 0 {
|
if logMaximum < 0 {
|
||||||
// negative log
|
// negative log
|
||||||
|
|
@ -74,7 +90,14 @@ func Plot(series []float64, options ...Option) string {
|
||||||
|
|
||||||
// axis and labels
|
// axis and labels
|
||||||
for y := intmin2; y < intmax2+1; y++ {
|
for y := intmin2; y < intmax2+1; y++ {
|
||||||
label := fmt.Sprintf("%*.*f", maxWidth+1, precision, maximum-(float64(y-intmin2)*interval/float64(rows)))
|
var magnitude float64
|
||||||
|
if rows > 0 {
|
||||||
|
magnitude = maximum - (float64(y-intmin2) * interval / float64(rows))
|
||||||
|
} else {
|
||||||
|
magnitude = float64(y)
|
||||||
|
}
|
||||||
|
|
||||||
|
label := fmt.Sprintf("%*.*f", maxWidth+1, precision, magnitude)
|
||||||
w := y - intmin2
|
w := y - intmin2
|
||||||
h := int(math.Max(float64(config.Offset)-float64(len(label)), 0))
|
h := int(math.Max(float64(config.Offset)-float64(len(label)), 0))
|
||||||
|
|
||||||
|
|
@ -99,12 +122,9 @@ func Plot(series []float64, options ...Option) string {
|
||||||
} else {
|
} else {
|
||||||
if y0 > y1 {
|
if y0 > y1 {
|
||||||
plot[rows-y1][x+config.Offset] = "╰"
|
plot[rows-y1][x+config.Offset] = "╰"
|
||||||
} else {
|
|
||||||
plot[rows-y1][x+config.Offset] = "╭"
|
|
||||||
}
|
|
||||||
if y0 > y1 {
|
|
||||||
plot[rows-y0][x+config.Offset] = "╮"
|
plot[rows-y0][x+config.Offset] = "╮"
|
||||||
} else {
|
} else {
|
||||||
|
plot[rows-y1][x+config.Offset] = "╭"
|
||||||
plot[rows-y0][x+config.Offset] = "╯"
|
plot[rows-y0][x+config.Offset] = "╯"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
13
vendor/github.com/carlosms/asciigraph/options.go
generated
vendored
13
vendor/github.com/carlosms/asciigraph/options.go
generated
vendored
|
|
@ -12,6 +12,7 @@ type Option interface {
|
||||||
// config holds various graph options
|
// config holds various graph options
|
||||||
type config struct {
|
type config struct {
|
||||||
Width, Height int
|
Width, Height int
|
||||||
|
Min, Max *float64
|
||||||
Offset int
|
Offset int
|
||||||
Caption string
|
Caption string
|
||||||
}
|
}
|
||||||
|
|
@ -54,6 +55,18 @@ func Height(h int) Option {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Min sets the graph's minimum value for the vertical axis. It will be ignored
|
||||||
|
// if the series contains a lower value.
|
||||||
|
func Min(min float64) Option {
|
||||||
|
return optionFunc(func(c *config) { c.Min = &min })
|
||||||
|
}
|
||||||
|
|
||||||
|
// Max sets the graph's maximum value for the vertical axis. It will be ignored
|
||||||
|
// if the series contains a bigger value.
|
||||||
|
func Max(max float64) Option {
|
||||||
|
return optionFunc(func(c *config) { c.Max = &max })
|
||||||
|
}
|
||||||
|
|
||||||
// Offset sets the graphs offset.
|
// Offset sets the graphs offset.
|
||||||
func Offset(o int) Option {
|
func Offset(o int) Option {
|
||||||
return optionFunc(func(c *config) { c.Offset = o })
|
return optionFunc(func(c *config) { c.Offset = o })
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue