mirror of
https://github.com/grafana/grafana.git
synced 2025-01-24 15:27:01 -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', () => {
|
test('simple conversion', () => {
|
||||||
const frame = toDataFrame({
|
const frame = toDataFrame({
|
||||||
fields: [
|
fields: [
|
||||||
{ type: FieldType.time, values: [1, 2, 3] },
|
{ type: FieldType.time, values: [1, 2, 3, 4, 5] },
|
||||||
{ name: 'first string field', values: ['t1', 't2', 't3'] },
|
{ name: 'first string field', values: ['t1', 't2', 't3', null, undefined] },
|
||||||
{ name: 'tags', values: ['aaa,bbb', 'bbb,ccc', 'zyz'] },
|
{ name: 'tags', values: ['aaa,bbb', 'bbb,ccc', 'zyz', null, undefined] },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -37,6 +37,12 @@ describe('DataFrame to annotations', () => {
|
|||||||
"text": "t3",
|
"text": "t3",
|
||||||
"time": 3,
|
"time": 3,
|
||||||
},
|
},
|
||||||
|
Object {
|
||||||
|
"time": 4,
|
||||||
|
},
|
||||||
|
Object {
|
||||||
|
"time": 5,
|
||||||
|
},
|
||||||
]
|
]
|
||||||
`);
|
`);
|
||||||
});
|
});
|
||||||
|
@ -175,8 +175,8 @@ export function getAnnotationsFromData(data: DataFrame[], options?: AnnotationEv
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v !== undefined) {
|
if (!(v === null || v === undefined)) {
|
||||||
if (f.split) {
|
if (v && f.split) {
|
||||||
v = (v as string).split(',');
|
v = (v as string).split(',');
|
||||||
}
|
}
|
||||||
(anno as any)[f.key] = v;
|
(anno as any)[f.key] = v;
|
||||||
|
Loading…
Reference in New Issue
Block a user