Skip to content

Commit

Permalink
[ML] don't display errors on init
Browse files Browse the repository at this point in the history
  • Loading branch information
darnautov committed May 20, 2021
1 parent b581f1c commit c31d336
Showing 1 changed file with 23 additions and 12 deletions.
35 changes: 23 additions & 12 deletions x-pack/plugins/lens/public/heatmap_visualization/visualization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,23 @@ export const isCellValueSupported = (op: OperationMetadata) => {
return !isBucketed(op) && (op.scale === 'ordinal' || op.scale === 'ratio') && isNumericMetric(op);
};

function getInitialState(): Omit<HeatmapVisualizationState, 'layerId'> {
return {
shape: CHART_SHAPES.HEATMAP,
legend: {
isVisible: true,
position: Position.Right,
type: LEGEND_FUNCTION,
},
gridConfig: {
type: HEATMAP_GRID_FUNCTION,
isCellLabelVisible: false,
isYAxisLabelVisible: true,
isXAxisLabelVisible: true,
},
};
}

export const getHeatmapVisualization = ({
paletteService,
}: HeatmapVisualizationDeps): Visualization<HeatmapVisualizationState> => ({
Expand Down Expand Up @@ -108,18 +125,7 @@ export const getHeatmapVisualization = ({
state || {
layerId: frame.addNewLayer(),
title: 'Empty Heatmap chart',
shape: CHART_SHAPES.HEATMAP,
legend: {
isVisible: true,
position: Position.Right,
type: LEGEND_FUNCTION,
},
gridConfig: {
type: HEATMAP_GRID_FUNCTION,
isCellLabelVisible: false,
isYAxisLabelVisible: true,
isXAxisLabelVisible: true,
},
...getInitialState(),
}
);
},
Expand Down Expand Up @@ -356,6 +362,11 @@ export const getHeatmapVisualization = ({
},

getErrorMessages(state) {
if (!state.yAccessor && !state.xAccessor && !state.valueAccessor) {
// nothing configured yet
return;
}

const errors: ReturnType<Visualization['getErrorMessages']> = [];

if (!state.xAccessor) {
Expand Down

0 comments on commit c31d336

Please sign in to comment.