Skip to content

Commit

Permalink
show warning message for the array values
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed Jun 4, 2021
1 parent d699e9e commit 4cb2f40
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import React from 'react';
import { render } from 'react-dom';
import { i18n } from '@kbn/i18n';
import { I18nProvider } from '@kbn/i18n/react';
import { FormattedMessage, I18nProvider } from '@kbn/i18n/react';
import { Ast } from '@kbn/interpreter/common';
import { Position } from '@elastic/charts';
import { PaletteRegistry } from '../../../../../src/plugins/charts/public';
Expand Down Expand Up @@ -386,4 +386,30 @@ export const getHeatmapVisualization = ({

return errors.length ? errors : undefined;
},

getWarningMessages(state, frame) {
if (!state?.layerId || !frame.activeData || !state.valueAccessor) {
return;
}

const rows = frame.activeData[state.layerId] && frame.activeData[state.layerId].rows;
if (!rows) {
return;
}

const hasArrayValues = rows.some((row) => Array.isArray(row[state.valueAccessor!]));

const datasource = frame.datasourceLayers[state.layerId];
const operation = datasource.getOperationForColumnId(state.valueAccessor);

return hasArrayValues
? [
<FormattedMessage
id="xpack.lens.heatmapVisualization.arrayValuesWarningMessage"
defaultMessage="{label} contains array values. Your visualization may not render as expected."
values={{ label: <strong>{operation?.label}</strong> }}
/>,
]
: undefined;
},
});

0 comments on commit 4cb2f40

Please sign in to comment.