Skip to content

Commit 946ea50

Browse files
authored
[7.x] [ML] Redesign file-based Data Visualizer (#87598) (#88863)
1 parent 87ee412 commit 946ea50

File tree

98 files changed

+1721
-1199
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1721
-1199
lines changed

x-pack/plugins/ml/common/types/file_datavisualizer.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7+
import { ES_FIELD_TYPES } from '../../../../../src/plugins/data/common';
8+
79
export interface InputOverrides {
810
[key: string]: string;
911
}
@@ -29,15 +31,27 @@ export interface FindFileStructureResponse {
2931
count: number;
3032
cardinality: number;
3133
top_hits: Array<{ count: number; value: any }>;
34+
mean_value?: number;
35+
median_value?: number;
3236
max_value?: number;
3337
min_value?: number;
38+
earliest?: string;
39+
latest?: string;
3440
};
3541
};
3642
sample_start: string;
3743
num_messages_analyzed: number;
3844
mappings: {
39-
[fieldName: string]: {
40-
type: string;
45+
properties: {
46+
[fieldName: string]: {
47+
// including all possible Elasticsearch types
48+
// since find_file_structure API can be enhanced to include new fields in the future
49+
type: Exclude<
50+
ES_FIELD_TYPES,
51+
ES_FIELD_TYPES._ID | ES_FIELD_TYPES._INDEX | ES_FIELD_TYPES._SOURCE | ES_FIELD_TYPES._TYPE
52+
>;
53+
format?: string;
54+
};
4155
};
4256
};
4357
quote: string;

x-pack/plugins/ml/common/types/ml_url_generator.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ export interface MlGenericUrlPageState extends MlIndexBasedSearchState {
4242
[key: string]: any;
4343
}
4444

45-
export interface DataVisualizerIndexBasedAppState {
46-
pageIndex: number;
47-
pageSize: number;
48-
sortField: string;
49-
sortDirection: string;
45+
export interface DataVisualizerIndexBasedAppState extends Omit<ListingPageUrlState, 'queryText'> {
5046
searchString?: Query['query'];
5147
searchQuery?: Query['query'];
5248
searchQueryLanguage?: SearchQueryLanguage;
@@ -57,6 +53,13 @@ export interface DataVisualizerIndexBasedAppState {
5753
showAllFields?: boolean;
5854
showEmptyFields?: boolean;
5955
}
56+
57+
export interface DataVisualizerFileBasedAppState extends Omit<ListingPageUrlState, 'queryText'> {
58+
visibleFieldTypes?: string[];
59+
visibleFieldNames?: string[];
60+
showDistributions?: boolean;
61+
}
62+
6063
export type MlGenericUrlState = MLPageState<
6164
| typeof ML_PAGES.DATA_VISUALIZER_INDEX_VIEWER
6265
| typeof ML_PAGES.ANOMALY_DETECTION_CREATE_JOB

x-pack/plugins/ml/public/application/components/data_grid/column_chart.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
.mlDataGridChart__legendBoolean {
2424
width: 100%;
25+
min-width: $euiButtonMinWidth;
2526
td { text-align: center }
2627
}
2728

x-pack/plugins/ml/public/application/components/data_grid/use_column_chart.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { NON_AGGREGATABLE } from './common';
2020

2121
export const hoveredRow$ = new BehaviorSubject<any | null>(null);
2222

23-
const BAR_COLOR = euiPaletteColorBlind()[0];
23+
export const BAR_COLOR = euiPaletteColorBlind()[0];
2424
const BAR_COLOR_BLUR = euiPaletteColorBlind({ rotations: 2 })[10];
2525
const MAX_CHART_COLUMNS = 20;
2626

x-pack/plugins/ml/public/application/components/field_title_bar/field_title_bar.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,15 @@ import { EuiText, EuiToolTip } from '@elastic/eui';
1111
import { i18n } from '@kbn/i18n';
1212

1313
import { FieldTypeIcon } from '../field_type_icon';
14-
import { FieldVisConfig } from '../../datavisualizer/index_based/common';
1514
import { getMLJobTypeAriaLabel } from '../../util/field_types_utils';
15+
import {
16+
FieldVisConfig,
17+
FileBasedFieldVisConfig,
18+
isIndexBasedFieldVisConfig,
19+
} from '../../datavisualizer/stats_table/types/field_vis_config';
1620

1721
interface Props {
18-
card: FieldVisConfig;
22+
card: FieldVisConfig | FileBasedFieldVisConfig;
1923
}
2024

2125
export const FieldTitleBar: FC<Props> = ({ card }) => {
@@ -30,13 +34,13 @@ export const FieldTitleBar: FC<Props> = ({ card }) => {
3034

3135
if (card.fieldName === undefined) {
3236
classNames.push('document_count');
33-
} else if (card.isUnsupportedType === true) {
37+
} else if (isIndexBasedFieldVisConfig(card) && card.isUnsupportedType === true) {
3438
classNames.push('type-other');
3539
} else {
3640
classNames.push(card.type);
3741
}
3842

39-
if (card.isUnsupportedType !== true) {
43+
if (isIndexBasedFieldVisConfig(card) && card.isUnsupportedType !== true) {
4044
// All the supported field types have aria labels.
4145
cardTitleAriaLabel.unshift(getMLJobTypeAriaLabel(card.type)!);
4246
}

x-pack/plugins/ml/public/application/data_frame_analytics/pages/analytics_management/components/analytics_list/use_table_settings.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
import { Direction, EuiBasicTableProps, Pagination, PropertySort } from '@elastic/eui';
88
import { useCallback, useMemo } from 'react';
99
import { ListingPageUrlState } from '../../../../../../../common/types/common';
10-
import { DataVisualizerIndexBasedAppState } from '../../../../../../../common/types/ml_url_generator';
10+
import {
11+
DataVisualizerFileBasedAppState,
12+
DataVisualizerIndexBasedAppState,
13+
} from '../../../../../../../common/types/ml_url_generator';
1114

1215
const PAGE_SIZE_OPTIONS = [10, 25, 50];
1316

@@ -38,7 +41,10 @@ interface UseTableSettingsReturnValue<T> {
3841

3942
export function useTableSettings<TypeOfItem>(
4043
items: TypeOfItem[],
41-
pageState: ListingPageUrlState | DataVisualizerIndexBasedAppState,
44+
pageState:
45+
| ListingPageUrlState
46+
| DataVisualizerIndexBasedAppState
47+
| DataVisualizerFileBasedAppState,
4248
updatePageState: (update: Partial<ListingPageUrlState>) => void
4349
): UseTableSettingsReturnValue<TypeOfItem> {
4450
const { pageIndex, pageSize, sortField, sortDirection } = pageState;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
@import 'file_based/index';
22
@import 'index_based/index';
3-
@import 'stats_datagrid/index';
3+
@import 'stats_table/index';
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
@import 'file_datavisualizer_view/index';
22
@import 'results_view/index';
33
@import 'analysis_summary/index';
4-
@import 'fields_stats/index';
54
@import 'about_panel/index';
65
@import 'import_summary/index';
76
@import 'experimental_badge/index';
Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,28 @@
44
* you may not use this file except in compliance with the Elastic License.
55
*/
66

7-
import { EuiPanel } from '@elastic/eui';
8-
import React, { FC } from 'react';
9-
10-
import { ML_JOB_FIELD_TYPES } from '../../../../../../common/constants/field_types';
11-
12-
import { FieldVisConfig } from '../../common';
13-
import { FieldTitleBar } from '../../../../components/field_title_bar/index';
7+
import React from 'react';
148
import {
159
BooleanContent,
1610
DateContent,
1711
GeoPointContent,
1812
IpContent,
1913
KeywordContent,
20-
NotInDocsContent,
21-
NumberContent,
2214
OtherContent,
2315
TextContent,
24-
} from './content_types';
25-
import { LoadingIndicator } from './loading_indicator';
26-
27-
export interface FieldDataCardProps {
28-
config: FieldVisConfig;
29-
}
16+
NumberContent,
17+
} from '../../../stats_table/components/field_data_expanded_row';
18+
import { ML_JOB_FIELD_TYPES } from '../../../../../../common/constants/field_types';
19+
import type { FileBasedFieldVisConfig } from '../../../stats_table/types/field_vis_config';
3020

31-
export const FieldDataCard: FC<FieldDataCardProps> = ({ config }) => {
32-
const { fieldName, loading, type, existsInDocs } = config;
21+
export const FileBasedDataVisualizerExpandedRow = ({ item }: { item: FileBasedFieldVisConfig }) => {
22+
const config = item;
23+
const { type, fieldName } = config;
3324

3425
function getCardContent() {
35-
if (existsInDocs === false) {
36-
return <NotInDocsContent />;
37-
}
38-
3926
switch (type) {
4027
case ML_JOB_FIELD_TYPES.NUMBER:
41-
if (fieldName !== undefined) {
42-
return <NumberContent config={config} />;
43-
} else {
44-
return null;
45-
}
28+
return <NumberContent config={config} />;
4629

4730
case ML_JOB_FIELD_TYPES.BOOLEAN:
4831
return <BooleanContent config={config} />;
@@ -68,15 +51,11 @@ export const FieldDataCard: FC<FieldDataCardProps> = ({ config }) => {
6851
}
6952

7053
return (
71-
<EuiPanel
72-
data-test-subj={`mlFieldDataCard ${fieldName} ${type}`}
73-
className="mlFieldDataCard"
74-
hasShadow={false}
54+
<div
55+
className="mlDataVisualizerFieldExpandedRow"
56+
data-test-subj={`mlDataVisualizerFieldExpandedRow-${fieldName}`}
7557
>
76-
<FieldTitleBar card={config} />
77-
<div className="mlFieldDataCard__content" data-test-subj="mlFieldDataCardContent">
78-
{loading === true ? <LoadingIndicator /> : getCardContent()}
79-
</div>
80-
</EuiPanel>
58+
{getCardContent()}
59+
</div>
8160
);
8261
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License;
4+
* you may not use this file except in compliance with the Elastic License.
5+
*/
6+
7+
export { FileBasedDataVisualizerExpandedRow } from './file_based_expanded_row';

0 commit comments

Comments
 (0)