Skip to content

Commit

Permalink
[ML] DF Analytics results view: ensure boolean values in charts shown…
Browse files Browse the repository at this point in the history
… without formatting (elastic#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
  • Loading branch information
alvarezmelissa87 committed Oct 6, 2020
1 parent 570f2d2 commit 5a8a5c5
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const ColumnChart: FC<Props> = ({ 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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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),
}));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,10 @@ export const ExplorationQueryBar: FC<ExplorationQueryBarProps> = ({
/>
</EuiFlexItem>
{filters && filters.options && (
<EuiFlexItem grow={false}>
<EuiFlexItem
grow={false}
data-test-subj="mlDFAnalyticsExplorationQueryBarFilterButtons"
>
<EuiButtonGroup
legend={i18n.translate(
'xpack.ml.dataframe.analytics.explorationQueryBar.buttonGroupLegend',
Expand All @@ -172,7 +175,6 @@ export const ExplorationQueryBar: FC<ExplorationQueryBarProps> = ({
}
)}
name="analyticsQueryBarFilterButtons"
data-test-subj="mlDFAnalyticsExplorationQueryBarFilterButtons"
options={filters.options}
type="multi"
idToSelectedMap={idToSelectedMap}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
},
Expand Down

0 comments on commit 5a8a5c5

Please sign in to comment.