[v10.0.x] Heatmap: Sort fields by numeric names when single frame (#69880)

Heatmap: Sort fields by numeric names when single frame (#69879)

(cherry picked from commit cc8bedc173)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2023-06-10 23:54:58 -06:00
committed by GitHub
co-authored by Leon Sorokin
parent 4184cd09f4
commit f7766f73b8
+14 -1
View File
@@ -108,7 +108,20 @@ export function prepareHeatmapData(
})!,
][0];
} else {
rowsHeatmap = frames[0];
let frame = frames[0];
let numberFields = frame.fields.filter((field) => field.type === FieldType.number);
let allNamesNumeric = numberFields.every((field) => !Number.isNaN(parseSampleValue(field.name)));
if (allNamesNumeric) {
numberFields.sort((a, b) => parseSampleValue(a.name) - parseSampleValue(b.name));
rowsHeatmap = {
...frame,
fields: [frame.fields.find((f) => f.type === FieldType.time)!, ...numberFields],
};
} else {
rowsHeatmap = frame;
}
}
}