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

This commit is contained in:
Leon Sorokin 2023-06-10 23:12:29 -05:00 committed by GitHub
parent 8d37d8f60b
commit cc8bedc173
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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;
}
}
}