mirror of
https://github.com/grafana/grafana.git
synced 2025-01-24 07:17:08 -06:00
Annotations: check for null or undefined fields before conversion (#27712)
This commit is contained in:
parent
f6c91d1318
commit
d46f33c34c
@ -5,9 +5,9 @@ describe('DataFrame to annotations', () => {
|
||||
test('simple conversion', () => {
|
||||
const frame = toDataFrame({
|
||||
fields: [
|
||||
{ type: FieldType.time, values: [1, 2, 3] },
|
||||
{ name: 'first string field', values: ['t1', 't2', 't3'] },
|
||||
{ name: 'tags', values: ['aaa,bbb', 'bbb,ccc', 'zyz'] },
|
||||
{ type: FieldType.time, values: [1, 2, 3, 4, 5] },
|
||||
{ name: 'first string field', values: ['t1', 't2', 't3', null, undefined] },
|
||||
{ name: 'tags', values: ['aaa,bbb', 'bbb,ccc', 'zyz', null, undefined] },
|
||||
],
|
||||
});
|
||||
|
||||
@ -37,6 +37,12 @@ describe('DataFrame to annotations', () => {
|
||||
"text": "t3",
|
||||
"time": 3,
|
||||
},
|
||||
Object {
|
||||
"time": 4,
|
||||
},
|
||||
Object {
|
||||
"time": 5,
|
||||
},
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
@ -175,8 +175,8 @@ export function getAnnotationsFromData(data: DataFrame[], options?: AnnotationEv
|
||||
}
|
||||
}
|
||||
|
||||
if (v !== undefined) {
|
||||
if (f.split) {
|
||||
if (!(v === null || v === undefined)) {
|
||||
if (v && f.split) {
|
||||
v = (v as string).split(',');
|
||||
}
|
||||
(anno as any)[f.key] = v;
|
||||
|
Loading…
Reference in New Issue
Block a user