Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ML] Redesign index-based Data Visualizer #85726

Merged
merged 84 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
3038aca
[ML] Add multi filter components
qn895 Nov 23, 2020
2783537
[ML] Add multi filter components
qn895 Nov 23, 2020
aa426b7
[ML] Add type to stats
qn895 Nov 23, 2020
8770f2c
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Nov 23, 2020
4084c4e
[ML] Replace with new grid
qn895 Nov 23, 2020
63f1607
[ML] Change order in Field Name
qn895 Nov 23, 2020
5b46da8
[ML] Some improvements to multi select picker
qn895 Nov 24, 2020
b8f5e32
[ML] Remove onchange call back
qn895 Nov 24, 2020
e87cc71
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Nov 24, 2020
3885bf4
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Nov 30, 2020
6cd9d2a
[ML] Add previews for distribution
qn895 Nov 30, 2020
0f7f8ba
[ML] Rename DataVisualizerFieldNamesFilter
qn895 Dec 1, 2020
2fcb76f
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Dec 1, 2020
2f00d2b
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Dec 2, 2020
76536d4
[ML] Save page state
qn895 Dec 2, 2020
8f24a38
[ML] Update search logic
qn895 Dec 2, 2020
f910267
[ML] Remove redundant changes
qn895 Dec 2, 2020
e78e001
[ML] Save field select params
qn895 Dec 2, 2020
57e56df
[ML] Update setters
qn895 Dec 2, 2020
012715d
[ML] Remember searchQuery
qn895 Dec 2, 2020
f326a10
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Dec 7, 2020
f462340
[ML] Update styling
qn895 Dec 7, 2020
d7d60ed
[ML] Update styling
qn895 Dec 7, 2020
07e922d
[ML] Add charts to keyword
qn895 Dec 7, 2020
11210e7
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Dec 9, 2020
5a857bc
[ML] Add alignment for type
qn895 Dec 9, 2020
d61271b
[ML] Fix typescript
qn895 Dec 9, 2020
7bac7ad
[ML] Update typescript for TopValuesPreview
qn895 Dec 9, 2020
8c18543
[ML] Update column test subj
qn895 Dec 9, 2020
ce54544
[ML] Move files into more appropriate folder
qn895 Dec 9, 2020
3e32e88
[ML] Update legend texts
qn895 Dec 9, 2020
68b4027
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Dec 10, 2020
2de29a7
[ML] Rename props
qn895 Dec 12, 2020
68086dc
[ML] Fix distro chart width
qn895 Dec 13, 2020
752d955
[ML] Fix order
qn895 Dec 13, 2020
2af418c
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Dec 13, 2020
d279c82
[ML] Consolidate search params update
qn895 Dec 13, 2020
a3d23cf
[ML] Reanem metricsloaded and nonmetricsloaded for clarity
qn895 Dec 13, 2020
2914d0f
[ML] Move total count header
qn895 Dec 13, 2020
e960a7e
[ML] Truncate legend text
qn895 Dec 13, 2020
9fed919
[ML] Add field stats control panels
qn895 Dec 13, 2020
8da6a06
[ML] Update translations and types
qn895 Dec 13, 2020
2cf4331
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Dec 13, 2020
c389c48
[ML] Update subject tests
qn895 Dec 13, 2020
9ce68bf
[ML] Update data subject tests
qn895 Dec 14, 2020
9e0f006
[ML] Update tests
qn895 Dec 14, 2020
0e3db85
[ML] Fix bug with nonmetric non-populated missing
qn895 Dec 14, 2020
6381ff9
[ML] Change 34,415 => 86,274
qn895 Dec 14, 2020
13fa2c8
[ML] Add i18n, rename multi select picker, remove comment
qn895 Dec 14, 2020
211c42a
[ML] Update saved search logic
qn895 Dec 14, 2020
958b660
Revert "[ML] Change 34,415 => 86,274"
qn895 Dec 14, 2020
c33a88f
[ML] Update totalDocCountFormatted back to what they were
qn895 Dec 14, 2020
5eed3fa
[ML] Update fieldDataCardExpandedRow i18n
qn895 Dec 14, 2020
3636822
[ML] Remove DataVisualizer from method naes in data_visualizer_index_…
qn895 Dec 14, 2020
395ed47
[ML] Fix count count, clarify assertTotalMetricFieldsCount
qn895 Dec 14, 2020
bd93f5a
[ML] Rearrange field count panel
qn895 Dec 14, 2020
0a04a37
[ML] Update translations
qn895 Dec 14, 2020
46d06b5
[ML] Fix mlDataVisualizerMetricFieldsCount
qn895 Dec 14, 2020
6a59811
[ML] Remove useRef
qn895 Dec 14, 2020
07ada1e
[ML] Fix MultiSelectPicker id
qn895 Dec 14, 2020
20ad0db
[ML] Update padding style, font, title case texts
qn895 Dec 14, 2020
609cef8
[ML] Fix top values header growing
qn895 Dec 14, 2020
37ac282
[ML] Fix top values header growing & changing pagination with jsx col…
qn895 Dec 14, 2020
0c34e8a
[ML] Update stylings
qn895 Dec 14, 2020
f5e326a
[ML] Move vertical spacer out to its own
qn895 Dec 14, 2020
05bb9f3
[ML] Update enum ML_JOB_FIELD_TYPES to const
qn895 Dec 14, 2020
13a460d
[ML] Update style boolean
qn895 Dec 14, 2020
eea52b8
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Dec 14, 2020
c8b6c9a
[ML] Update styling
qn895 Dec 15, 2020
36497eb
[ML] Update MlJobFieldType in test
qn895 Dec 15, 2020
b470034
[ML] Performance improvements for anomaly
qn895 Dec 15, 2020
078cb94
[ML] Performance improvements for anomaly
qn895 Dec 15, 2020
286a76b
[ML] Update top 10 preview labels
qn895 Dec 15, 2020
4ea6d17
[ML] Remove any for FieldVisStats and multi select, use guttersize, r…
qn895 Dec 15, 2020
59e11f9
[ML] Update colors of charts, styling, paddings
qn895 Dec 15, 2020
a021855
[ML] Add type for OverallStats, remove flex groups
qn895 Dec 15, 2020
30c0394
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Dec 15, 2020
3305f1a
Merge remote-tracking branch 'upstream/master' into ml-datavisualizer…
qn895 Dec 15, 2020
0dcdf2e
[ML] Update styling
qn895 Dec 15, 2020
87a1377
[ML] Update translations
qn895 Dec 15, 2020
b2abf17
[ML] Update paddings
qn895 Dec 15, 2020
7c3da1a
[ML] Remove div
qn895 Dec 15, 2020
4bbcbf0
[ML] Fix styling of distributions
qn895 Dec 15, 2020
c16d60d
[ML] Add padding to percent value
qn895 Dec 15, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions x-pack/plugins/ml/common/constants/field_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/

export enum ML_JOB_FIELD_TYPES {
BOOLEAN = 'boolean',
DATE = 'date',
GEO_POINT = 'geo_point',
IP = 'ip',
KEYWORD = 'keyword',
NUMBER = 'number',
TEXT = 'text',
UNKNOWN = 'unknown',
}
export const ML_JOB_FIELD_TYPES = {
BOOLEAN: 'boolean',
DATE: 'date',
GEO_POINT: 'geo_point',
IP: 'ip',
KEYWORD: 'keyword',
NUMBER: 'number',
TEXT: 'text',
UNKNOWN: 'unknown',
} as const;

export const MLCATEGORY = 'mlcategory';

Expand Down
24 changes: 24 additions & 0 deletions x-pack/plugins/ml/common/types/datavisualizer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export interface AggregatableField {
fieldName: string;
stats: {
cardinality?: number;
count?: number;
sampleCount?: number;
};
existsInDocs: boolean;
}

export type NonAggregatableField = Omit<AggregatableField, 'stats'>;
export interface OverallStats {
totalCount: number;
aggregatableExistsFields: AggregatableField[];
aggregatableNotExistsFields: NonAggregatableField[];
nonAggregatableExistsFields: AggregatableField[];
nonAggregatableNotExistsFields: NonAggregatableField[];
}
9 changes: 9 additions & 0 deletions x-pack/plugins/ml/common/types/field_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { ML_JOB_FIELD_TYPES } from '../constants/field_types';

export type MlJobFieldType = typeof ML_JOB_FIELD_TYPES[keyof typeof ML_JOB_FIELD_TYPES];
29 changes: 24 additions & 5 deletions x-pack/plugins/ml/common/types/ml_url_generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { RefreshInterval, TimeRange } from '../../../../../src/plugins/data/common/query';
import { JobId } from './anomaly_detection_jobs/job';
import type {
Query,
RefreshInterval,
TimeRange,
} from '../../../../../src/plugins/data/common/query';
import type { JobId } from './anomaly_detection_jobs/job';
import { ML_PAGES } from '../constants/ml_url_generator';
import { DataFrameAnalysisConfigType } from './data_frame_analytics';
import { SearchQueryLanguage } from '../constants/search';
import { ListingPageUrlState } from './common';
import type { DataFrameAnalysisConfigType } from './data_frame_analytics';
import type { SearchQueryLanguage } from '../constants/search';
import type { ListingPageUrlState } from './common';

type OptionalPageState = object | undefined;

Expand Down Expand Up @@ -38,6 +42,21 @@ export interface MlGenericUrlPageState extends MlIndexBasedSearchState {
[key: string]: any;
}

export interface DataVisualizerIndexBasedAppState {
pageIndex: number;
pageSize: number;
sortField: string;
sortDirection: string;
searchString?: Query['query'];
searchQuery?: Query['query'];
searchQueryLanguage?: SearchQueryLanguage;
visibleFieldTypes?: string[];
visibleFieldNames?: string[];
samplerShardSize?: number;
showDistributions?: boolean;
showAllFields?: boolean;
showEmptyFields?: boolean;
}
export type MlGenericUrlState = MLPageState<
| typeof ML_PAGES.DATA_VISUALIZER_INDEX_VIEWER
| typeof ML_PAGES.ANOMALY_DETECTION_CREATE_JOB
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,34 +18,41 @@ interface Props {
chartData: ChartData;
columnType: EuiDataGridColumn;
dataTestSubj: string;
hideLabel?: boolean;
maxChartColumns?: number;
}

export const ColumnChart: FC<Props> = ({ chartData, columnType, dataTestSubj }) => {
const { data, legendText, xScaleType } = useColumnChart(chartData, columnType);
const columnChartTheme = {
background: { color: 'transparent' },
chartMargins: {
left: 0,
right: 0,
top: 0,
bottom: 1,
},
chartPaddings: {
left: 0,
right: 0,
top: 0,
bottom: 0,
},
scales: { barsPadding: 0.1 },
};
export const ColumnChart: FC<Props> = ({
chartData,
columnType,
dataTestSubj,
hideLabel,
maxChartColumns,
}) => {
const { data, legendText, xScaleType } = useColumnChart(chartData, columnType, maxChartColumns);

return (
<div data-test-subj={dataTestSubj}>
{!isUnsupportedChartData(chartData) && data.length > 0 && (
<div className="mlDataGridChart__histogram" data-test-subj={`${dataTestSubj}-histogram`}>
<Chart>
<Settings
theme={{
background: { color: 'transparent' },
chartMargins: {
left: 0,
right: 0,
top: 0,
bottom: 1,
},
chartPaddings: {
left: 0,
right: 0,
top: 0,
bottom: 0,
},
scales: { barsPadding: 0.1 },
}}
/>
<Settings theme={columnChartTheme} />
<BarSeries
id="histogram"
name="count"
Expand All @@ -68,7 +75,7 @@ export const ColumnChart: FC<Props> = ({ chartData, columnType, dataTestSubj })
>
{legendText}
</div>
<div data-test-subj={`${dataTestSubj}-id`}>{columnType.id}</div>
{!hideLabel && <div data-test-subj={`${dataTestSubj}-id`}>{columnType.id}</div>}
</div>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ export const isNumericChartData = (arg: any): arg is NumericChartData => {
);
};

interface OrdinalDataItem {
export interface OrdinalDataItem {
key: string;
key_as_string?: string;
doc_count: number;
}

interface OrdinalChartData {
export interface OrdinalChartData {
type: 'ordinal' | 'boolean';
cardinality: number;
data: OrdinalDataItem[];
Expand All @@ -120,11 +120,14 @@ export const isUnsupportedChartData = (arg: any): arg is UnsupportedChartData =>
return arg.hasOwnProperty('type') && arg.type === 'unsupported';
};

type ChartDataItem = NumericDataItem | OrdinalDataItem;
export type ChartDataItem = NumericDataItem | OrdinalDataItem;
export type ChartData = NumericChartData | OrdinalChartData | UnsupportedChartData;

type LegendText = string | JSX.Element;
const getLegendText = (chartData: ChartData): LegendText => {
export const getLegendText = (
chartData: ChartData,
maxChartColumns = MAX_CHART_COLUMNS
): LegendText => {
if (chartData.type === 'unsupported') {
return i18n.translate('xpack.ml.dataGridChart.histogramNotAvailable', {
defaultMessage: 'Chart not supported.',
Expand All @@ -150,17 +153,17 @@ const getLegendText = (chartData: ChartData): LegendText => {
);
}

if (isOrdinalChartData(chartData) && chartData.cardinality <= MAX_CHART_COLUMNS) {
if (isOrdinalChartData(chartData) && chartData.cardinality <= maxChartColumns) {
return i18n.translate('xpack.ml.dataGridChart.singleCategoryLegend', {
defaultMessage: `{cardinality, plural, one {# category} other {# categories}}`,
values: { cardinality: chartData.cardinality },
});
}

if (isOrdinalChartData(chartData) && chartData.cardinality > MAX_CHART_COLUMNS) {
if (isOrdinalChartData(chartData) && chartData.cardinality > maxChartColumns) {
return i18n.translate('xpack.ml.dataGridChart.topCategoriesLegend', {
defaultMessage: `top {MAX_CHART_COLUMNS} of {cardinality} categories`,
values: { cardinality: chartData.cardinality, MAX_CHART_COLUMNS },
defaultMessage: `top {maxChartColumns} of {cardinality} categories`,
values: { cardinality: chartData.cardinality, maxChartColumns },
});
}

Expand All @@ -182,7 +185,8 @@ interface ColumnChart {

export const useColumnChart = (
chartData: ChartData,
columnType: EuiDataGridColumn
columnType: EuiDataGridColumn,
maxChartColumns?: number
): ColumnChart => {
const fieldType = getFieldType(columnType.schema);

Expand Down Expand Up @@ -244,7 +248,7 @@ export const useColumnChart = (

return {
data,
legendText: getLegendText(chartData),
legendText: getLegendText(chartData, maxChartColumns),
xScaleType,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import { i18n } from '@kbn/i18n';

import { getMLJobTypeAriaLabel } from '../../util/field_types_utils';
import { ML_JOB_FIELD_TYPES } from '../../../../common/constants/field_types';
import type { MlJobFieldType } from '../../../../common/types/field_types';

interface FieldTypeIconProps {
tooltipEnabled: boolean;
type: ML_JOB_FIELD_TYPES;
type: MlJobFieldType;
fieldName?: string;
needsAria: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { MultiSelectPicker, Option } from './multi_select_picker';
Loading