mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-12 06:24:10 +01:00
console: exclude 0 from minimum value
This commit is contained in:
@@ -231,8 +231,16 @@ func (c *Component) graphHandlerFunc(gc *gin.Context) {
|
|||||||
s := make([]int, len(rowValues[r]))
|
s := make([]int, len(rowValues[r]))
|
||||||
copy(s, rowValues[r])
|
copy(s, rowValues[r])
|
||||||
sort.Ints(s)
|
sort.Ints(s)
|
||||||
output.Min[idx] = s[0]
|
// Min (but not 0)
|
||||||
|
for i := 0; i < len(s); i++ {
|
||||||
|
output.Min[idx] = s[i]
|
||||||
|
if s[i] > 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Max
|
||||||
output.Max[idx] = s[len(s)-1]
|
output.Max[idx] = s[len(s)-1]
|
||||||
|
// 95th percentile
|
||||||
index := 0.95 * float64(len(s))
|
index := 0.95 * float64(len(s))
|
||||||
j := int(index)
|
j := int(index)
|
||||||
if index == float64(j) {
|
if index == float64(j) {
|
||||||
|
|||||||
@@ -215,9 +215,9 @@ func TestGraphHandler(t *testing.T) {
|
|||||||
"min": []int{
|
"min": []int{
|
||||||
2000,
|
2000,
|
||||||
100,
|
100,
|
||||||
0,
|
1200,
|
||||||
0,
|
1100,
|
||||||
0,
|
100,
|
||||||
100,
|
100,
|
||||||
},
|
},
|
||||||
"max": []int{
|
"max": []int{
|
||||||
|
|||||||
Reference in New Issue
Block a user