mirror of
https://github.com/akvorado/akvorado.git
synced 2025-12-11 22:14:02 +01:00
console: ensure "Other" is last when returning data
This commit is contained in:
@@ -185,10 +185,16 @@ watch([fetchedData, isDark], ([data, isDark]) => {
|
||||
itemStyle: {
|
||||
color: color(idx, false, theme),
|
||||
},
|
||||
lineStyle: {
|
||||
color: color(idx, false, theme),
|
||||
width: 1,
|
||||
},
|
||||
lineStyle:
|
||||
idx == data.rows.length - 1
|
||||
? {
|
||||
color: isDark ? "#ddd" : "#111",
|
||||
width: 2,
|
||||
}
|
||||
: {
|
||||
color: color(idx, false, theme),
|
||||
width: 1,
|
||||
},
|
||||
areaStyle: {
|
||||
opacity: 0.95,
|
||||
color: new graphic.LinearGradient(0, 0, 0, 1, [
|
||||
|
||||
@@ -481,7 +481,14 @@ func (c *Component) graphHandlerFunc(gc *gin.Context) {
|
||||
rows[i] = k
|
||||
i++
|
||||
}
|
||||
// Sort by sum, except we want "Other" to be last
|
||||
sort.Slice(rows, func(i, j int) bool {
|
||||
if rowKeys[rows[i]][0] == "Other" {
|
||||
return false
|
||||
}
|
||||
if rowKeys[rows[j]][0] == "Other" {
|
||||
return true
|
||||
}
|
||||
return rowSums[rows[i]] > rowSums[rows[j]]
|
||||
})
|
||||
output.Rows = make([][]string, len(rows))
|
||||
|
||||
@@ -418,11 +418,11 @@ func TestGraphHandler(t *testing.T) {
|
||||
// Sorted by sum of bps
|
||||
"rows": [][]string{
|
||||
{"router1", "provider2"}, // 10000
|
||||
{"Other", "Other"}, // 2100
|
||||
{"router1", "provider1"}, // 1600
|
||||
{"router2", "provider2"}, // 1200
|
||||
{"router2", "provider3"}, // 1100
|
||||
{"router2", "provider4"}, // 1000
|
||||
{"Other", "Other"}, // 2100
|
||||
},
|
||||
"t": []string{
|
||||
"2009-11-10T23:00:00Z",
|
||||
@@ -431,35 +431,35 @@ func TestGraphHandler(t *testing.T) {
|
||||
},
|
||||
"points": [][]int{
|
||||
{2000, 5000, 3000},
|
||||
{1900, 100, 100},
|
||||
{1000, 500, 100},
|
||||
{1200, 0, 0},
|
||||
{1100, 0, 0},
|
||||
{0, 900, 100},
|
||||
{1900, 100, 100},
|
||||
},
|
||||
"min": []int{
|
||||
2000,
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
100,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
},
|
||||
"max": []int{
|
||||
5000,
|
||||
1900,
|
||||
1000,
|
||||
1200,
|
||||
1100,
|
||||
900,
|
||||
1900,
|
||||
},
|
||||
"average": []int{
|
||||
3333,
|
||||
700,
|
||||
533,
|
||||
400,
|
||||
366,
|
||||
333,
|
||||
700,
|
||||
},
|
||||
}
|
||||
mockConn.EXPECT().
|
||||
|
||||
Reference in New Issue
Block a user