diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/common/fields.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/common/fields.ts index f9c9bf26a9d16..e4581f0a87bdd 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/common/fields.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/common/fields.ts @@ -48,6 +48,8 @@ export const EXTENDED_NUMERICAL_TYPES = new Set([ // eslint-disable-next-line @typescript-eslint/naming-convention export const ML__ID_COPY = 'ml__id_copy'; +// eslint-disable-next-line @typescript-eslint/naming-convention +export const ML__INCREMENTAL_ID = 'ml__incremental_id'; export const isKeywordAndTextType = (fieldName: string): boolean => { const { fields } = newJobCapsService; diff --git a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/use_outlier_data.ts b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/use_outlier_data.ts index 151e5ea4e6feb..eded8e82a7919 100644 --- a/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/use_outlier_data.ts +++ b/x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_exploration/components/outlier_exploration/use_outlier_data.ts @@ -31,10 +31,19 @@ import { getToastNotifications } from '../../../../../util/dependency_cache'; import { getIndexData, getIndexFields, DataFrameAnalyticsConfig } from '../../../../common'; import { FEATURE_INFLUENCE } from '../../../../common/constants'; import { DEFAULT_RESULTS_FIELD } from '../../../../../../../common/constants/data_frame_analytics'; -import { sortExplorationResultsFields, ML__ID_COPY } from '../../../../common/fields'; +import { + sortExplorationResultsFields, + ML__ID_COPY, + ML__INCREMENTAL_ID, +} from '../../../../common/fields'; import { getFeatureCount, getOutlierScoreFieldName } from './common'; +interface FeatureInfluence { + feature_name: string; + influence: number; +} + export const useOutlierData = ( indexPattern: IndexPattern | undefined, jobConfig: DataFrameAnalyticsConfig | undefined, @@ -61,7 +70,7 @@ export const useOutlierData = ( // reduce default selected rows from 20 to 8 for performance reasons. 8, // by default, hide feature-influence columns and the doc id copy - (d) => !d.includes(`.${FEATURE_INFLUENCE}.`) && d !== ML__ID_COPY + (d) => !d.includes(`.${FEATURE_INFLUENCE}.`) && d !== ML__ID_COPY && d !== ML__INCREMENTAL_ID ); useEffect(() => { @@ -138,9 +147,16 @@ export const useOutlierData = ( // column with feature values get color coded by its corresponding influencer value if ( fullItem[resultsField] !== undefined && - fullItem[resultsField][`${FEATURE_INFLUENCE}.${columnId}`] !== undefined + fullItem[resultsField][FEATURE_INFLUENCE] !== undefined && + fullItem[resultsField][FEATURE_INFLUENCE].find( + (d: FeatureInfluence) => d.feature_name === columnId + ) !== undefined ) { - backgroundColor = colorRange(fullItem[resultsField][`${FEATURE_INFLUENCE}.${columnId}`]); + backgroundColor = colorRange( + fullItem[resultsField][FEATURE_INFLUENCE].find( + (d: FeatureInfluence) => d.feature_name === columnId + ).influence + ); } // column with influencer values get color coded by its own value