Commit d46f33c3 by Ryan McKinley Committed by GitHub

Annotations: check for null or undefined fields before conversion (#27712)

parent f6c91d13
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment