mirror of https://github.com/grafana/grafana
GraphNG: support x != time in library (#29353)
parent
0b451486f8
commit
9dbf54eb61
@ -0,0 +1,42 @@ |
|||||||
|
import { Field, FieldType, DataFrame } from '../../types/dataFrame'; |
||||||
|
import { FieldMatcherID } from './ids'; |
||||||
|
import { FieldMatcherInfo } from '../../types/transformations'; |
||||||
|
|
||||||
|
const firstFieldMatcher: FieldMatcherInfo = { |
||||||
|
id: FieldMatcherID.first, |
||||||
|
name: 'First Field', |
||||||
|
description: 'The first field in the frame', |
||||||
|
|
||||||
|
get: (type: FieldType) => { |
||||||
|
return (field: Field, frame: DataFrame, allFrames: DataFrame[]) => { |
||||||
|
return field === frame.fields[0]; |
||||||
|
}; |
||||||
|
}, |
||||||
|
|
||||||
|
getOptionsDisplayText: () => { |
||||||
|
return `First field`; |
||||||
|
}, |
||||||
|
}; |
||||||
|
|
||||||
|
const firstTimeFieldMatcher: FieldMatcherInfo = { |
||||||
|
id: FieldMatcherID.firstTimeField, |
||||||
|
name: 'First time field', |
||||||
|
description: 'The first field of type time in a frame', |
||||||
|
|
||||||
|
get: (type: FieldType) => { |
||||||
|
return (field: Field, frame: DataFrame, allFrames: DataFrame[]) => { |
||||||
|
return field.type === FieldType.time && field === frame.fields.find(f => f.type === FieldType.time); |
||||||
|
}; |
||||||
|
}, |
||||||
|
|
||||||
|
getOptionsDisplayText: () => { |
||||||
|
return `First time field`; |
||||||
|
}, |
||||||
|
}; |
||||||
|
|
||||||
|
/** |
||||||
|
* Registry Initialization |
||||||
|
*/ |
||||||
|
export function getSimpleFieldMatchers(): FieldMatcherInfo[] { |
||||||
|
return [firstFieldMatcher, firstTimeFieldMatcher]; |
||||||
|
} |
Loading…
Reference in new issue