Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
567f088
Initialize Data comparison view (Refactor & fix conflicts from poc PR)
qn895 Jul 5, 2023
a3dc124
Clean up
qn895 Jul 5, 2023
f991036
Renaming
qn895 Jul 6, 2023
9ea789b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jul 6, 2023
0ec0ed3
Add tests
qn895 Jul 10, 2023
61c5da3
[ML] Refactor to data visualizer & its own packages
qn895 Jul 10, 2023
5afb8a8
[ML] Fix git missing some moved files
qn895 Jul 11, 2023
5bf40bc
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 11, 2023
f33968b
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine Jul 11, 2023
60ecf83
Fix types
qn895 Jul 11, 2023
108969a
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 11, 2023
7dbc4f8
Update imports for SearchQueryLanguage and SEARCH_QUERY_LANGUAGE to b…
qn895 Jul 11, 2023
25156e9
Update imports for useTableState to be from '@kbn/ml-in-memory-table'
qn895 Jul 11, 2023
a129654
Add callout message for non time-series data view
qn895 Jul 11, 2023
cca0ffe
Fix aggegations undefined
qn895 Jul 11, 2023
b13fa68
Allow to modify badge width
qn895 Jul 11, 2023
c3d43fa
Fix progress message
qn895 Jul 11, 2023
1ad5425
Added progress message
qn895 Jul 11, 2023
7a2425a
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 11, 2023
1ff283e
Fix hook being called multiple times
qn895 Jul 11, 2023
f9a2527
Fix pagination
qn895 Jul 12, 2023
c6d7f31
Add dynamic import of constants
qn895 Jul 12, 2023
70e2226
Retry dynamic import of constants
qn895 Jul 12, 2023
5f64e5c
Merge remote-tracking branch 'upstream/main' into data-drift-part-1
qn895 Jul 12, 2023
0a9d733
Revert "Retry dynamic import of constants"
qn895 Jul 13, 2023
d45db0e
Revert "Add dynamic import of constants"
qn895 Jul 13, 2023
f2eec5d
Rename production to comparison
qn895 Jul 14, 2023
37a9bcb
Fix table loading messages
qn895 Jul 14, 2023
e219b07
Renaming of components and files for consistency
qn895 Jul 14, 2023
cc1bacb
Replace with chi2test from @stdlib/stats
qn895 Jul 16, 2023
b0f2685
Replace with chi2test from @stdlib/stats
qn895 Jul 16, 2023
86eef58
Refactor components
qn895 Jul 16, 2023
ca1fe67
Refactor labels
qn895 Jul 16, 2023
207468b
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jul 16, 2023
49c5db7
Fix OverlapDistributionComparison chart missing
qn895 Jul 16, 2023
3beb38f
Add better visibility for error messages
qn895 Jul 16, 2023
4340a15
Add random sampling
qn895 Jul 16, 2023
54179e3
Refactor ProbabilityUsedMessage
qn895 Jul 17, 2023
111644c
Merge remote-tracking branch 'upstream/main' into data-drift-part-1
qn895 Jul 17, 2023
2f4441c
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Jul 17, 2023
cc1ac29
Test lazy wrapper
qn895 Jul 17, 2023
7b7cf0d
Merge branch 'data-drift-part-1' of https://github.com/qn895/kibana i…
qn895 Jul 17, 2023
887bd36
Test lazy wrapper 2
qn895 Jul 17, 2023
ab84bb0
Add random sampling
qn895 Jul 18, 2023
3820359
Ensure error messages propagate up
qn895 Jul 18, 2023
3143103
Add NoChartsData
qn895 Jul 18, 2023
2ddbb91
Add approx sign
qn895 Jul 18, 2023
9592e1c
Merge remote-tracking branch 'upstream/main' into data-drift-part-1
qn895 Jul 19, 2023
4db8e78
[@To be reverted] Test if @stdlib/esm reduces bundle size
qn895 Jul 19, 2023
6a696d2
[@To be reverted] Test if @stdlib/esm reduces bundle size
qn895 Jul 19, 2023
8f713d2
Merge branch 'data-drift-part-1' of https://github.com/qn895/kibana i…
qn895 Jul 19, 2023
a695856
Revert test if @stdlib/esm reduces bundle size
qn895 Jul 19, 2023
3bf5998
Test no critical tables, no package
qn895 Jul 19, 2023
f93c320
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jul 19, 2023
31fbee2
No more testing
qn895 Jul 20, 2023
1b19e66
Renaming & import type
qn895 Jul 20, 2023
895edd9
Add ability to cancel request
qn895 Jul 20, 2023
509a389
Fix force refresh
qn895 Jul 20, 2023
42295a5
Add deep link for data comparison
qn895 Jul 19, 2023
1e965d2
Merge remote-tracking branch 'upstream/main' into data-drift-part-1
qn895 Jul 24, 2023
6b17764
Fix types
qn895 Jul 24, 2023
c35bd60
[ML] Add comments to aiops-component
qn895 Jul 25, 2023
bf34f73
[ML] Fix issue with no agg, comment, remove any
qn895 Jul 26, 2023
f4a76d5
Revert api doc changes
qn895 Jul 26, 2023
f5ed74f
Rename typo ComparisonHistogram
qn895 Jul 26, 2023
0622573
Add field type icon
qn895 Jul 26, 2023
0a4ea12
Fix in memory comments
qn895 Jul 26, 2023
16c7ebd
Merge branch 'main' into data-drift-part-1
kibanamachine Jul 26, 2023
bb91294
Remove todo
qn895 Jul 27, 2023
3021ebf
Merge remote-tracking branch 'upstream/main' into data-drift-part-1
qn895 Jul 27, 2023
7c9f899
Merge upstream/main into branch
qn895 Jul 28, 2023
8c8d116
Fix SearchQueryLanguage
qn895 Jul 28, 2023
159241e
Merge branch 'main' into data-drift-part-1
kibanamachine Jul 31, 2023
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
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,7 @@ x-pack/packages/ml/data_grid @elastic/ml-ui
x-pack/packages/ml/date_picker @elastic/ml-ui
x-pack/packages/ml/date_utils @elastic/ml-ui
x-pack/packages/ml/error_utils @elastic/ml-ui
x-pack/packages/ml/in_memory_table @elastic/ml-ui
x-pack/packages/ml/is_defined @elastic/ml-ui
x-pack/packages/ml/is_populated_object @elastic/ml-ui
x-pack/packages/ml/kibana_theme @elastic/ml-ui
Expand Down
2 changes: 1 addition & 1 deletion api_docs/kbn_aiops_components.devdocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,4 @@
"misc": [],
"objects": []
}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@
"@kbn/ml-date-picker": "link:x-pack/packages/ml/date_picker",
"@kbn/ml-date-utils": "link:x-pack/packages/ml/date_utils",
"@kbn/ml-error-utils": "link:x-pack/packages/ml/error_utils",
"@kbn/ml-in-memory-table": "link:x-pack/packages/ml/in_memory_table",
"@kbn/ml-is-defined": "link:x-pack/packages/ml/is_defined",
"@kbn/ml-is-populated-object": "link:x-pack/packages/ml/is_populated_object",
"@kbn/ml-kibana-theme": "link:x-pack/packages/ml/kibana_theme",
Expand Down
1 change: 1 addition & 0 deletions packages/deeplinks/ml/deep_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export type LinkId =
| 'anomalyDetection'
| 'anomalyExplorer'
| 'singleMetricViewer'
| 'dataComparison'
| 'dataFrameAnalytics'
| 'resultExplorer'
| 'analyticsMap'
Expand Down
2 changes: 2 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,8 @@
"@kbn/ml-date-utils/*": ["x-pack/packages/ml/date_utils/*"],
"@kbn/ml-error-utils": ["x-pack/packages/ml/error_utils"],
"@kbn/ml-error-utils/*": ["x-pack/packages/ml/error_utils/*"],
"@kbn/ml-in-memory-table": ["x-pack/packages/ml/in_memory_table"],
"@kbn/ml-in-memory-table/*": ["x-pack/packages/ml/in_memory_table/*"],
"@kbn/ml-is-defined": ["x-pack/packages/ml/is_defined"],
"@kbn/ml-is-defined/*": ["x-pack/packages/ml/is_defined/*"],
"@kbn/ml-is-populated-object": ["x-pack/packages/ml/is_populated_object"],
Expand Down
2 changes: 2 additions & 0 deletions x-pack/packages/ml/aiops_components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@

export { DualBrush, DualBrushAnnotation } from './src/dual_brush';
export { ProgressControls } from './src/progress_controls';
export { DocumentCountChart } from './src/document_count_chart';
export type { DocumentCountChartPoint, DocumentCountChartProps } from './src/document_count_chart';
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ interface BrushBadgeProps {
width: number;
}

/**
* Badge component
* @param label - label
* @param marginLeft - margin left
* @param timestampFrom - start timestamp
* @param timestampTo - ending timestamp
* @param width - width of badge
* @constructor
*/
export const BrushBadge: FC<BrushBadgeProps> = ({
label,
marginLeft,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,20 @@ import {

import { i18n } from '@kbn/i18n';
import { IUiSettingsClient } from '@kbn/core/public';
import { DualBrush, DualBrushAnnotation } from '@kbn/aiops-components';
import { getSnappedWindowParameters, getWindowParameters } from '@kbn/aiops-utils';
import type { WindowParameters } from '@kbn/aiops-utils';
import { MULTILAYER_TIME_AXIS_STYLE } from '@kbn/charts-plugin/common';

import { useAiopsAppContext } from '../../../hooks/use_aiops_app_context';
import {
BarStyleAccessor,
RectAnnotationSpec,
} from '@elastic/charts/dist/chart_types/xy_chart/utils/specs';

import type { DataPublicPluginStart } from '@kbn/data-plugin/public';
import type { ChartsPluginStart } from '@kbn/charts-plugin/public';
import type { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
import { BrushBadge } from './brush_badge';
import { DualBrush, DualBrushAnnotation } from '../..';

declare global {
interface Window {
Expand All @@ -46,27 +52,79 @@ interface TimeFilterRange {
to: number;
}

/**
* Datum for the bar chart
*/
export interface DocumentCountChartPoint {
/**
* Time of bucket
*/
time: number | string;
/**
* Number of doc count for that time bucket
*/
value: number;
}

interface DocumentCountChartProps {
brushSelectionUpdateHandler?: (d: WindowParameters, force: boolean) => void;
/**
* Brush settings
*/
export interface BrushSettings {
/**
* Optional label name for brush
*/
label?: string;
/**
* Optional style for brush
*/
annotationStyle?: RectAnnotationSpec['style'];
/**
* Optional width for brush
*/
badgeWidth?: number;
}

/**
* Props for document count chart
*/
export interface DocumentCountChartProps {
/** List of Kibana services that are required as dependencies */
dependencies: {
data: DataPublicPluginStart;
charts: ChartsPluginStart;
fieldFormats: FieldFormatsStart;
uiSettings: IUiSettingsClient;
};
/** Optional callback function which gets called the brush selection has changed */
brushSelectionUpdateHandler?: (windowParameters: WindowParameters, force: boolean) => void;
/** Optional width */
width?: number;
/** Data chart points */
chartPoints: DocumentCountChartPoint[];
/** Data chart points split */
chartPointsSplit?: DocumentCountChartPoint[];
/** Start time range for the chart */
timeRangeEarliest: number;
/** Ending time range for the chart */
timeRangeLatest: number;
/** Time interval for the document count buckets */
interval: number;
/** Label to name the adjustedChartPointsSplit histogram */
chartPointsSplitLabel: string;
/** Whether or not brush has been reset */
isBrushCleared: boolean;
/* Timestamp for start of initial analysis */
/** Timestamp for start of initial analysis */
autoAnalysisStart?: number | WindowParameters;
/** Optional style to override bar chart */
barStyleAccessor?: BarStyleAccessor;
/** Optional color override for the default bar color for charts */
barColorOverride?: string;
/** Optional color override for the highlighted bar color for charts */
barHighlightColorOverride?: string;
/** Optional settings override for the 'deviation' brush */
deviationBrush?: BrushSettings;
/** Optional settings override for the 'baseline' brush */
baselineBrush?: BrushSettings;
}

const SPEC_ID = 'document_count';
Expand Down Expand Up @@ -102,7 +160,29 @@ function getBaselineBadgeOverflow(
: 0;
}

/**
* Document count chart with draggable brushes to select time ranges
* by default use `Baseline` and `Deviation` for the badge names
* @param dependencies - List of Kibana services that are required as dependencies
* @param brushSelectionUpdateHandler - Optional callback function which gets called the brush selection has changed
* @param width - Optional width
* @param chartPoints - Data chart points
* @param chartPointsSplit - Data chart points split
* @param timeRangeEarliest - Start time range for the chart
* @param timeRangeLatest - Ending time range for the chart
* @param interval - Time interval for the document count buckets
* @param chartPointsSplitLabel - Label to name the adjustedChartPointsSplit histogram
* @param isBrushCleared - Whether or not brush has been reset
* @param autoAnalysisStart - Timestamp for start of initial analysis
* @param barColorOverride - Optional color override for the default bar color for charts
* @param barStyleAccessor - Optional style to override bar chart
* @param barHighlightColorOverride - Optional color override for the highlighted bar color for charts
* @param deviationBrush - Optional settings override for the 'deviation' brush
* @param baselineBrush - Optional settings override for the 'baseline' brush
* @constructor
*/
export const DocumentCountChart: FC<DocumentCountChartProps> = ({
dependencies,
brushSelectionUpdateHandler,
width,
chartPoints,
Expand All @@ -114,9 +194,12 @@ export const DocumentCountChart: FC<DocumentCountChartProps> = ({
isBrushCleared,
autoAnalysisStart,
barColorOverride,
barStyleAccessor,
barHighlightColorOverride,
deviationBrush = {},

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Passing some additional optional overrides here

baselineBrush = {},
}) => {
const { data, uiSettings, fieldFormats, charts } = useAiopsAppContext();
const { data, uiSettings, fieldFormats, charts } = dependencies;

const chartTheme = charts.theme.useChartsTheme();
const chartBaseTheme = charts.theme.useChartsBaseTheme();
Expand Down Expand Up @@ -339,22 +422,28 @@ export const DocumentCountChart: FC<DocumentCountChartProps> = ({
<div className="aiopsHistogramBrushes" data-test-subj="aiopsHistogramBrushes">
<div css={{ height: BADGE_HEIGHT }}>
<BrushBadge
label={i18n.translate('xpack.aiops.documentCountChart.baselineBadgeLabel', {
defaultMessage: 'Baseline',
})}
label={
baselineBrush.label ??
i18n.translate('xpack.aiops.documentCountChart.baselineBadgeLabel', {
defaultMessage: 'Baseline',
})
}
marginLeft={baselineBadgeMarginLeft - baselineBadgeOverflow}
timestampFrom={windowParameters.baselineMin}
timestampTo={windowParameters.baselineMax}
width={BADGE_WIDTH}
width={baselineBrush.badgeWidth ?? BADGE_WIDTH}
/>
<BrushBadge
label={i18n.translate('xpack.aiops.documentCountChart.deviationBadgeLabel', {
defaultMessage: 'Deviation',
})}
label={
deviationBrush.label ??
i18n.translate('xpack.aiops.documentCountChart.deviationBadgeLabel', {
defaultMessage: 'Deviation',
})
}
marginLeft={mlBrushMarginLeft + (windowParametersAsPixels?.deviationMin ?? 0)}
timestampFrom={windowParameters.deviationMin}
timestampTo={windowParameters.deviationMax}
width={BADGE_WIDTH}
width={deviationBrush.badgeWidth ?? BADGE_WIDTH}
/>
</div>
<div
Expand Down Expand Up @@ -416,6 +505,7 @@ export const DocumentCountChart: FC<DocumentCountChartProps> = ({
timeZone={timeZone}
color={barColor}
yNice
styleAccessor={barStyleAccessor}
/>
)}
{adjustedChartPointsSplit?.length && (
Expand All @@ -438,11 +528,13 @@ export const DocumentCountChart: FC<DocumentCountChartProps> = ({
id="aiopsBaseline"
min={windowParameters.baselineMin}
max={windowParameters.baselineMax}
style={baselineBrush.annotationStyle}
/>
<DualBrushAnnotation
id="aiopsDeviation"
min={windowParameters.deviationMin}
max={windowParameters.deviationMax}
style={deviationBrush.annotationStyle}
/>
</>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
*/

export { DocumentCountChart } from './document_count_chart';
export type { DocumentCountChartPoint } from './document_count_chart';
export type { DocumentCountChartPoint, DocumentCountChartProps } from './document_count_chart';
49 changes: 49 additions & 0 deletions x-pack/packages/ml/aiops_components/src/dual_brush/dual_brush.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,71 @@ const BRUSH_HANDLE_SIZE = 4;
const BRUSH_HANDLE_ROUNDED_CORNER = 2;

interface DualBrushProps {
/**
* Min and max numeric timestamps for the two brushes
*/
windowParameters: WindowParameters;
/**
* Min timestamp for x domain
*/
min: number;
/**
* Max timestamp for x domain
*/
max: number;
/**
* Callback function whenever the brush changes
*/
onChange?: (windowParameters: WindowParameters, windowPxParameters: WindowParameters) => void;
/**
* Margin left
*/
marginLeft: number;
/**
* Nearest timestamps to snap to the brushes to
*/
snapTimestamps?: number[];
/**
* Width
*/
width: number;
}

/**
* DualBrush React Component
* Dual brush component that overlays the document count chart
* @type {FC<DualBrushProps>}
* @param props - `DualBrushProps` component props
* @returns {React.ReactElement} The DualBrush component.
*/
export function DualBrush({
/**
* Min and max numeric timestamps for the two brushes
*/
windowParameters,
/**
* Min timestamp for x domain
*/
min,
/**
* Max timestamp for x domain
*/
max,
/**
* Callback function whenever the brush changes
*/
onChange,
/**
* Margin left
*/
marginLeft,
/**
* Nearest timestamps to snap to the brushes to
*/
snapTimestamps,
/**
* Width
*/
width,
}: DualBrushProps) {
const d3BrushContainer = useRef(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,23 @@ import React, { FC } from 'react';

import { RectAnnotation } from '@elastic/charts';
import { useEuiTheme } from '@elastic/eui';
import { RectAnnotationSpec } from '@elastic/charts/dist/chart_types/xy_chart/utils/specs';

interface BrushAnnotationProps {
id: string;
min: number;
max: number;
style?: RectAnnotationSpec['style'];
}

export const DualBrushAnnotation: FC<BrushAnnotationProps> = ({ id, min, max }) => {
/**
* DualBrushAnnotation React Component
* Dual brush annotation component that overlays the document count chart
* @type {FC<BrushAnnotationProps>}
* @param props - `BrushAnnotationProps` component props
* @returns {React.ReactElement} The DualBrushAnnotation component.
*/
export const DualBrushAnnotation: FC<BrushAnnotationProps> = ({ id, min, max, style }) => {
const { euiTheme } = useEuiTheme();
const { colors } = euiTheme;

Expand All @@ -34,12 +43,14 @@ export const DualBrushAnnotation: FC<BrushAnnotationProps> = ({ id, min, max })
},
]}
id={`rect_brush_annotation_${id}`}
style={{
strokeWidth: 0,
stroke: colors.lightShade,
fill: colors.lightShade,
opacity: 0.5,
}}
style={
style ?? {
strokeWidth: 0,
stroke: colors.lightShade,
fill: colors.lightShade,
opacity: 0.5,
}
}
hideTooltips={true}
/>
);
Expand Down
Loading