mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
@@ -923,12 +923,6 @@ exports[`better eslint`] = {
|
||||
"packages/grafana-ui/src/components/VizLegend/VizLegendListItem.tsx:5381": [
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/VizLegend/VizLegendTable.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"]
|
||||
],
|
||||
"packages/grafana-ui/src/components/VizLegend/types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
|
||||
@@ -44,12 +44,10 @@ export const VizLegendTable = <T extends unknown>({
|
||||
}
|
||||
|
||||
if (sortKey != null) {
|
||||
let itemVals = new Map<VizLegendItem, string | number>();
|
||||
let itemVals = new Map<VizLegendItem, number>();
|
||||
|
||||
items.forEach((item) => {
|
||||
if (sortKey === nameSortKey) {
|
||||
itemVals.set(item, item.label);
|
||||
} else if (item.getDisplayValues) {
|
||||
if (sortKey !== nameSortKey && item.getDisplayValues) {
|
||||
const stat = item.getDisplayValues().find((stat) => stat.title === sortKey);
|
||||
const val = stat == null || Number.isNaN(stat.numeric) ? -Infinity : stat.numeric;
|
||||
itemVals.set(item, val);
|
||||
@@ -61,16 +59,13 @@ export const VizLegendTable = <T extends unknown>({
|
||||
if (sortKey === nameSortKey) {
|
||||
// string sort
|
||||
items.sort((a, b) => {
|
||||
let aVal = itemVals.get(a) as string;
|
||||
let bVal = itemVals.get(b) as string;
|
||||
|
||||
return sortMult * naturalCompare(aVal, bVal);
|
||||
return sortMult * naturalCompare(a.label, b.label);
|
||||
});
|
||||
} else {
|
||||
// numeric sort
|
||||
items.sort((a, b) => {
|
||||
let aVal = itemVals.get(a) as number;
|
||||
let bVal = itemVals.get(b) as number;
|
||||
const aVal = itemVals.get(a) ?? 0;
|
||||
const bVal = itemVals.get(b) ?? 0;
|
||||
|
||||
return sortMult * (aVal - bVal);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user