Skip to content

Commit ee80e2d

Browse files
committed
[ML] Fix color coding for outlier detection. Fix nested fields for data gird.
1 parent 62b8498 commit ee80e2d

File tree

2 files changed

+24
-7
lines changed
  • x-pack/plugins/ml/public/application
    • components/data_grid
    • data_frame_analytics/pages/analytics_exploration/components/outlier_exploration

2 files changed

+24
-7
lines changed

x-pack/plugins/ml/public/application/components/data_grid/common.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,24 @@ export const useRenderCellValue = (
208208
return results[cId.replace(`${resultsField}.`, '')];
209209
}
210210

211-
return tableItems.hasOwnProperty(adjustedRowIndex)
212-
? getNestedProperty(tableItems[adjustedRowIndex], cId, null)
213-
: null;
211+
if (tableItems.hasOwnProperty(adjustedRowIndex)) {
212+
const item = tableItems[adjustedRowIndex];
213+
214+
// Try if the field name is available as is.
215+
if (item.hasOwnProperty(cId)) {
216+
return item[cId];
217+
}
218+
219+
// Try if the field name is available as a nested field.
220+
return getNestedProperty(tableItems[adjustedRowIndex], cId, null);
221+
}
222+
223+
return null;
214224
}
215225

216226
const cellValue = getCellValue(columnId);
217227

218-
// React by default doesn't all us to use a hook in a callback.
228+
// React by default doesn't allow us to use a hook in a callback.
219229
// However, this one will be passed on to EuiDataGrid and its docs
220230
// recommend wrapping `setCellProps` in a `useEffect()` hook
221231
// so we're ignoring the linting rule here.

x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/common.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,14 @@ export const getFeatureCount = (resultsField: string, tableItems: DataGridItem[]
1717
return 0;
1818
}
1919

20-
return Object.keys(tableItems[0]).filter((key) =>
21-
key.includes(`${resultsField}.${FEATURE_INFLUENCE}.`)
22-
).length;
20+
const fullItem = tableItems[0];
21+
22+
if (
23+
fullItem[resultsField] !== undefined &&
24+
Array.isArray(fullItem[resultsField][FEATURE_INFLUENCE])
25+
) {
26+
return fullItem[resultsField][FEATURE_INFLUENCE].length;
27+
}
28+
29+
return 0;
2330
};

0 commit comments

Comments
 (0)