Skip to content

Commit 4cb2f40

Browse files
committed
show warning message for the array values
1 parent d699e9e commit 4cb2f40

1 file changed

Lines changed: 27 additions & 1 deletion

File tree

x-pack/plugins/lens/public/heatmap_visualization/visualization.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import React from 'react';
99
import { render } from 'react-dom';
1010
import { i18n } from '@kbn/i18n';
11-
import { I18nProvider } from '@kbn/i18n/react';
11+
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
1212
import { Ast } from '@kbn/interpreter/common';
1313
import { Position } from '@elastic/charts';
1414
import { PaletteRegistry } from '../../../../../src/plugins/charts/public';
@@ -386,4 +386,30 @@ export const getHeatmapVisualization = ({
386386

387387
return errors.length ? errors : undefined;
388388
},
389+
390+
getWarningMessages(state, frame) {
391+
if (!state?.layerId || !frame.activeData || !state.valueAccessor) {
392+
return;
393+
}
394+
395+
const rows = frame.activeData[state.layerId] && frame.activeData[state.layerId].rows;
396+
if (!rows) {
397+
return;
398+
}
399+
400+
const hasArrayValues = rows.some((row) => Array.isArray(row[state.valueAccessor!]));
401+
402+
const datasource = frame.datasourceLayers[state.layerId];
403+
const operation = datasource.getOperationForColumnId(state.valueAccessor);
404+
405+
return hasArrayValues
406+
? [
407+
<FormattedMessage
408+
id="xpack.lens.heatmapVisualization.arrayValuesWarningMessage"
409+
defaultMessage="{label} contains array values. Your visualization may not render as expected."
410+
values={{ label: <strong>{operation?.label}</strong> }}
411+
/>,
412+
]
413+
: undefined;
414+
},
389415
});

0 commit comments

Comments
 (0)