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