From feb2b458f5a2d46c027e29b0fb283c7fdee1b4c9 Mon Sep 17 00:00:00 2001 From: Dima Arnautov Date: Thu, 3 Jun 2021 12:00:47 +0200 Subject: [PATCH] [ML] filter out undefined values --- .../lens/public/heatmap_visualization/chart_component.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/lens/public/heatmap_visualization/chart_component.tsx b/x-pack/plugins/lens/public/heatmap_visualization/chart_component.tsx index 930a7e9b6acb5..45951f056f743 100644 --- a/x-pack/plugins/lens/public/heatmap_visualization/chart_component.tsx +++ b/x-pack/plugins/lens/public/heatmap_visualization/chart_component.tsx @@ -50,8 +50,6 @@ export const HeatmapComponent: FC = ({ const tableId = Object.keys(data.tables)[0]; const table = data.tables[tableId]; - let chartData = table.rows; - const xAxisColumnIndex = table.columns.findIndex((v) => v.id === args.xAccessor); const yAxisColumnIndex = table.columns.findIndex((v) => v.id === args.yAccessor); @@ -64,6 +62,8 @@ export const HeatmapComponent: FC = ({ return null; } + let chartData = table.rows.filter((v) => typeof v[args.valueAccessor!] === 'number'); + if (!yAxisColumn) { // required for tooltip chartData = chartData.map((row) => { @@ -77,6 +77,8 @@ export const HeatmapComponent: FC = ({ const xAxisMeta = xAxisColumn.meta; const isTimeBasedSwimLane = xAxisMeta.type === 'date'; + // Fallback to the ordinal scale type when a single row of data is provided. + // Related issue https://github.com/elastic/elastic-charts/issues/1184 const xScaleType = isTimeBasedSwimLane && chartData.length > 1 ? ScaleType.Time : ScaleType.Ordinal;