mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-18 02:35:57 +08:00
fix: table sorting when units are present (#5249)
This commit is contained in:
parent
f1b5da9916
commit
2a4e97f8da
@ -62,10 +62,11 @@ function GridTableComponent({
|
|||||||
|
|
||||||
mutateDataSource = mutateDataSource.map(
|
mutateDataSource = mutateDataSource.map(
|
||||||
(val): RowData => {
|
(val): RowData => {
|
||||||
const newValue = val;
|
const newValue = { ...val };
|
||||||
Object.keys(val).forEach((k) => {
|
Object.keys(val).forEach((k) => {
|
||||||
if (columnUnits[k]) {
|
if (columnUnits[k]) {
|
||||||
newValue[k] = getYAxisFormattedValue(String(val[k]), columnUnits[k]);
|
newValue[k] = getYAxisFormattedValue(String(val[k]), columnUnits[k]);
|
||||||
|
newValue[`${k}_without_unit`] = val[k];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return newValue;
|
return newValue;
|
||||||
@ -81,7 +82,6 @@ function GridTableComponent({
|
|||||||
applyColumnUnits,
|
applyColumnUnits,
|
||||||
originalDataSource,
|
originalDataSource,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (tableProcessedDataRef) {
|
if (tableProcessedDataRef) {
|
||||||
// eslint-disable-next-line no-param-reassign
|
// eslint-disable-next-line no-param-reassign
|
||||||
|
@ -537,8 +537,12 @@ const generateTableColumns = (
|
|||||||
width: QUERY_TABLE_CONFIG.width,
|
width: QUERY_TABLE_CONFIG.width,
|
||||||
render: renderColumnCell && renderColumnCell[item.dataIndex],
|
render: renderColumnCell && renderColumnCell[item.dataIndex],
|
||||||
sorter: (a: RowData, b: RowData): number => {
|
sorter: (a: RowData, b: RowData): number => {
|
||||||
const valueA = Number(a[item.dataIndex]);
|
const valueA = Number(
|
||||||
const valueB = Number(b[item.dataIndex]);
|
a[`${item.dataIndex}_without_unit`] ?? a[item.dataIndex],
|
||||||
|
);
|
||||||
|
const valueB = Number(
|
||||||
|
b[`${item.dataIndex}_without_unit`] ?? b[item.dataIndex],
|
||||||
|
);
|
||||||
|
|
||||||
if (!isNaN(valueA) && !isNaN(valueB)) {
|
if (!isNaN(valueA) && !isNaN(valueB)) {
|
||||||
return valueA - valueB;
|
return valueA - valueB;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user