From 4c65b6dda4fb309dde68cf76bd7ad093ac1d3023 Mon Sep 17 00:00:00 2001 From: Melissa Alvarez Date: Tue, 6 Oct 2020 14:37:47 -0400 Subject: [PATCH] [ML] DF Analytics results view: ensure boolean values in charts shown without formatting (#78888) * add functional test for searchBar filters. remove boolean schema from datagrid * always use string version of key for charts * add schema back in for histogram label * use ?? instead of || for undefined check --- .../application/components/data_grid/column_chart.tsx | 2 +- .../application/components/data_grid/use_column_chart.tsx | 4 +++- .../exploration_query_bar/exploration_query_bar.tsx | 6 ++++-- .../apps/ml/data_frame_analytics/classification_creation.ts | 1 + .../apps/ml/data_frame_analytics/regression_creation.ts | 1 + .../functional/services/ml/data_frame_analytics_results.ts | 6 ++++++ 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/ml/public/application/components/data_grid/column_chart.tsx b/x-pack/plugins/ml/public/application/components/data_grid/column_chart.tsx index a3a67fbb8bb75..97fac052df1f6 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/column_chart.tsx +++ b/x-pack/plugins/ml/public/application/components/data_grid/column_chart.tsx @@ -51,7 +51,7 @@ export const ColumnChart: FC = ({ chartData, columnType, dataTestSubj }) name="count" xScaleType={xScaleType} yScaleType="linear" - xAccessor="key" + xAccessor={'key_as_string'} yAccessors={['doc_count']} styleAccessor={(d) => d.datum.color} data={data} diff --git a/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx b/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx index 6b5fbbb22120d..a3169dc14a3a8 100644 --- a/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx +++ b/x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx @@ -67,7 +67,7 @@ export const getFieldType = (schema: EuiDataGridColumn['schema']): KBN_FIELD_TYP interface NumericDataItem { key: number; - key_as_string?: string; + key_as_string?: string | number; doc_count: number; } @@ -231,11 +231,13 @@ export const useColumnChart = ( if (isOrdinalChartData(chartData)) { data = chartData.data.map((d: OrdinalDataItem) => ({ ...d, + key_as_string: d.key_as_string ?? d.key, color: getColor(d), })); } else if (isNumericChartData(chartData)) { data = chartData.data.map((d: NumericDataItem) => ({ ...d, + key_as_string: d.key_as_string || d.key, color: getColor(d), })); } diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx index c2f3e71e2e492..06bcdfd364d66 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/exploration_query_bar/exploration_query_bar.tsx @@ -163,7 +163,10 @@ export const ExplorationQueryBar: FC = ({ /> {filters && filters.options && ( - + = ({ } )} name="analyticsQueryBarFilterButtons" - data-test-subj="mlDFAnalyticsExplorationQueryBarFilterButtons" options={filters.options} type="multi" idToSelectedMap={idToSelectedMap} diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts index e12c853a0be83..5ff2039ac80e4 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/classification_creation.ts @@ -205,6 +205,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.dataFrameAnalyticsResults.assertClassificationEvaluatePanelElementsExists(); await ml.dataFrameAnalyticsResults.assertClassificationTablePanelExists(); await ml.dataFrameAnalyticsResults.assertResultsTableExists(); + await ml.dataFrameAnalyticsResults.assertResultsTableTrainingFiltersExist(); await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty(); }); }); diff --git a/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts b/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts index c58220f2d1ad2..dad3d990cfcaa 100644 --- a/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts +++ b/x-pack/test/functional/apps/ml/data_frame_analytics/regression_creation.ts @@ -205,6 +205,7 @@ export default function ({ getService }: FtrProviderContext) { await ml.dataFrameAnalyticsResults.assertRegressionEvaluatePanelElementsExists(); await ml.dataFrameAnalyticsResults.assertRegressionTablePanelExists(); await ml.dataFrameAnalyticsResults.assertResultsTableExists(); + await ml.dataFrameAnalyticsResults.assertResultsTableTrainingFiltersExist(); await ml.dataFrameAnalyticsResults.assertResultsTableNotEmpty(); }); }); diff --git a/x-pack/test/functional/services/ml/data_frame_analytics_results.ts b/x-pack/test/functional/services/ml/data_frame_analytics_results.ts index a4d8fa8e692bd..8781a2cd216f2 100644 --- a/x-pack/test/functional/services/ml/data_frame_analytics_results.ts +++ b/x-pack/test/functional/services/ml/data_frame_analytics_results.ts @@ -43,6 +43,12 @@ export function MachineLearningDataFrameAnalyticsResultsProvider({ await testSubjects.existOrFail('mlExplorationDataGrid loaded', { timeout: 5000 }); }, + async assertResultsTableTrainingFiltersExist() { + await testSubjects.existOrFail('mlDFAnalyticsExplorationQueryBarFilterButtons', { + timeout: 5000, + }); + }, + async getResultTableRows() { return await testSubjects.findAll('mlExplorationDataGrid loaded > dataGridRow'); },