diff --git a/packages/grafana-data/src/field/displayProcessor.test.ts b/packages/grafana-data/src/field/displayProcessor.test.ts index 3bae9138192..7cb49137e7a 100644 --- a/packages/grafana-data/src/field/displayProcessor.test.ts +++ b/packages/grafana-data/src/field/displayProcessor.test.ts @@ -460,7 +460,7 @@ describe('getRawDisplayProcessor', () => { ${'a string'} | ${'a string'} ${null} | ${'null'} ${undefined} | ${'undefined'} - ${{ value: 0, label: 'a label' }} | ${'[object Object]'} + ${{ value: 0, label: 'a label' }} | ${'{"value":0,"label":"a label"}'} `('when called with value:{$value}', ({ value, expected }) => { const result = processor(value); diff --git a/packages/grafana-data/src/field/displayProcessor.ts b/packages/grafana-data/src/field/displayProcessor.ts index 7e09960c4a7..a8bab9f7ac6 100644 --- a/packages/grafana-data/src/field/displayProcessor.ts +++ b/packages/grafana-data/src/field/displayProcessor.ts @@ -11,6 +11,7 @@ import { KeyValue, TimeZone } from '../types'; import { getScaleCalculator } from './scale'; import { GrafanaTheme2 } from '../themes/types'; import { anyToNumber } from '../utils/anyToNumber'; +import { getFieldTypeFromValue } from '../dataframe/processDataFrame'; interface DisplayProcessorOptions { field: Partial; @@ -168,7 +169,20 @@ function toStringProcessor(value: any): DisplayValue { export function getRawDisplayProcessor(): DisplayProcessor { return (value: any) => ({ - text: `${value}`, + text: getFieldTypeFromValue(value) === 'other' ? `${JSON.stringify(value, getCircularReplacer())}` : `${value}`, numeric: null as unknown as number, }); } + +const getCircularReplacer = () => { + const seen = new WeakSet(); + return (_key: any, value: object | null) => { + if (typeof value === 'object' && value !== null) { + if (seen.has(value)) { + return; + } + seen.add(value); + } + return value; + }; +};