mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
StreamingDataFrame: skip empty labels (#36047)
This commit is contained in:
parent
d42d874240
commit
429e2d0ab2
@ -1,4 +1,5 @@
|
||||
import { reduceField, ReducerID } from '..';
|
||||
import { getFieldDisplayName } from '../field';
|
||||
import { DataFrame, FieldType } from '../types/dataFrame';
|
||||
import { DataFrameJSON } from './DataFrameJSON';
|
||||
import { StreamingDataFrame } from './StreamingDataFrame';
|
||||
@ -352,6 +353,27 @@ describe('Streaming JSON', () => {
|
||||
},
|
||||
]
|
||||
`);
|
||||
|
||||
// Push value with empty labels
|
||||
stream.push({
|
||||
data: {
|
||||
values: [[''], [500], [50], [7]],
|
||||
},
|
||||
});
|
||||
|
||||
expect(stream.fields.map((f) => getFieldDisplayName(f, stream, [stream]))).toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"time",
|
||||
"speed A",
|
||||
"light A",
|
||||
"speed B",
|
||||
"light B",
|
||||
"speed C",
|
||||
"light C",
|
||||
"speed 4",
|
||||
"light 4",
|
||||
]
|
||||
`); // speed+light 4 ¯\_(ツ)_/¯ better than undefined labels
|
||||
});
|
||||
|
||||
/*
|
||||
|
@ -186,11 +186,12 @@ export class StreamingDataFrame implements DataFrame {
|
||||
|
||||
// parse labels
|
||||
const parsedLabels: Labels = {};
|
||||
|
||||
label.split(',').forEach((kv) => {
|
||||
const [key, val] = kv.trim().split('=');
|
||||
parsedLabels[key] = val;
|
||||
});
|
||||
if (label.length) {
|
||||
label.split(',').forEach((kv) => {
|
||||
const [key, val] = kv.trim().split('=');
|
||||
parsedLabels[key] = val;
|
||||
});
|
||||
}
|
||||
|
||||
if (labelCount === 0) {
|
||||
// mutate existing fields and add labels
|
||||
|
Loading…
Reference in New Issue
Block a user