mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
TablePanel: Sort numbers correctly (#25421)
* Table sortType to basic to be able to sort negative numbers * Table sortType based on field type
This commit is contained in:
parent
70038bfd5b
commit
5f767e2c9a
@ -35,7 +35,7 @@ export function getTextAlign(field?: Field): TextAlignProperty {
|
||||
}
|
||||
|
||||
export function getColumns(data: DataFrame, availableWidth: number, columnMinWidth: number): Column[] {
|
||||
const columns: Column[] = [];
|
||||
const columns: any[] = [];
|
||||
let fieldCountWithoutWidth = data.fields.length;
|
||||
|
||||
for (const [fieldIndex, field] of data.fields.entries()) {
|
||||
@ -50,6 +50,15 @@ export function getColumns(data: DataFrame, availableWidth: number, columnMinWid
|
||||
fieldCountWithoutWidth -= 1;
|
||||
}
|
||||
|
||||
const selectSortType = (type: FieldType): string => {
|
||||
switch (type) {
|
||||
case FieldType.number:
|
||||
case FieldType.time:
|
||||
return 'basic';
|
||||
default:
|
||||
return 'alphanumeric';
|
||||
}
|
||||
};
|
||||
const Cell = getCellComponent(fieldTableOptions.displayMode, field);
|
||||
columns.push({
|
||||
Cell,
|
||||
@ -58,6 +67,7 @@ export function getColumns(data: DataFrame, availableWidth: number, columnMinWid
|
||||
accessor: (row: any, i: number) => {
|
||||
return field.values.get(i);
|
||||
},
|
||||
sortType: selectSortType(field.type),
|
||||
width: fieldTableOptions.width,
|
||||
minWidth: 50,
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user