NodeGraph: Fix sorting markers in grid view (#35200) (#35216)

* Fix test data field label

* Fix sorting

* Changed icon for sorting

(cherry picked from commit 1dc387536e)

Co-authored-by: Andrej Ocenas <mr.ocenas@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-06-04 09:55:03 +02:00
committed by GitHub
co-authored by Andrej Ocenas
parent 6f9ecceb9f
commit 9439b6acba
3 changed files with 5 additions and 5 deletions
@@ -172,7 +172,7 @@ export const nodes = {
{
name: NodeGraphDataFrameFieldNames.arc + 'faults',
type: FieldType.number,
config: { color: { mode: FieldColorModeId.Fixed, fixedColor: 'red' }, displayName: 'faults' },
config: { color: { mode: FieldColorModeId.Fixed, fixedColor: 'red' }, displayName: 'Faults' },
values: [
0,
0,
@@ -38,7 +38,7 @@ export const Legend = function Legend(props: Props) {
(item) => {
onSort({
field: item.data!.field,
ascending: item.data!.field === sort?.field ? !sort?.ascending : true,
ascending: item.data!.field === sort?.field ? !sort?.ascending : false,
});
},
[sort, onSort]
@@ -55,7 +55,7 @@ export const Legend = function Legend(props: Props) {
<>
<VizLegendListItem item={item} className={styles.item} onLabelClick={sortable ? onClick : undefined} />
{sortable &&
(sort?.field === item.data!.field ? <Icon name={sort!.ascending ? 'angle-up' : 'angle-down'} /> : '')}
(sort?.field === item.data!.field ? <Icon name={sort!.ascending ? 'arrow-up' : 'arrow-down'} /> : '')}
</>
);
}}
+2 -2
View File
@@ -174,8 +174,8 @@ function gridLayout(
const val1 = sort!.field.values.get(node1.dataFrameRowIndex);
const val2 = sort!.field.values.get(node2.dataFrameRowIndex);
// Lets pretend we don't care about type for a while
return sort!.ascending ? val2 - val1 : val1 - val2;
// Lets pretend we don't care about type of the stats for a while (they can be strings)
return sort!.ascending ? val1 - val2 : val2 - val1;
});
}