mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
graph: the stack & legend sort sync was not working correctly, the z-index sorting that happened in after the legend sort order was applied and messed with the order even though the sort function returned zero for all entries, combined the sort function to one sort function, fixes #9789 (#9797)
This commit is contained in:
parent
c44f6e2ec2
commit
685ee393af
@ -375,20 +375,8 @@ function graphDirective($rootScope, timeSrv, popoverSrv, contextSrv) {
|
|||||||
var sortOrder = panel.legend.sortDesc;
|
var sortOrder = panel.legend.sortDesc;
|
||||||
var haveSortBy = sortBy !== null || sortBy !== undefined;
|
var haveSortBy = sortBy !== null || sortBy !== undefined;
|
||||||
var haveSortOrder = sortOrder !== null || sortOrder !== undefined;
|
var haveSortOrder = sortOrder !== null || sortOrder !== undefined;
|
||||||
|
var shouldSortBy = panel.stack && haveSortBy && haveSortOrder;
|
||||||
if (panel.stack && haveSortBy && haveSortOrder) {
|
var sortDesc = panel.legend.sortDesc === true ? -1 : 1;
|
||||||
var desc = desc = panel.legend.sortDesc === true ? -1 : 1;
|
|
||||||
series.sort((x, y) => {
|
|
||||||
if (x.stats[sortBy] > y.stats[sortBy]) {
|
|
||||||
return 1 * desc;
|
|
||||||
}
|
|
||||||
if (x.stats[sortBy] < y.stats[sortBy]) {
|
|
||||||
return -1 * desc;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
series.sort((x, y) => {
|
series.sort((x, y) => {
|
||||||
if (x.zindex > y.zindex) {
|
if (x.zindex > y.zindex) {
|
||||||
@ -399,6 +387,15 @@ function graphDirective($rootScope, timeSrv, popoverSrv, contextSrv) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldSortBy) {
|
||||||
|
if (x.stats[sortBy] > y.stats[sortBy]) {
|
||||||
|
return 1 * sortDesc;
|
||||||
|
}
|
||||||
|
if (x.stats[sortBy] < y.stats[sortBy]) {
|
||||||
|
return -1 * sortDesc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user