Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Add UX support for HC detector (#314)
Browse files Browse the repository at this point in the history
* Support HC detector on UI
  • Loading branch information
yizheliu-amazon authored Oct 20, 2020
1 parent 40dcfde commit 8829407
Show file tree
Hide file tree
Showing 39 changed files with 5,200 additions and 713 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,10 @@
"@types/node": "^12.6.8",
"@types/react": "^16.8.23",
"@types/react-dom": "^16.8.4",
"@types/react-plotly.js": "^2.2.4",
"@types/react-redux": "^7.1.1",
"@types/react-router-dom": "^4.3.4",
"@types/react-vis": "^1.11.3",
"@types/redux-mock-store": "^1.0.1",
"babel-eslint": "^9.0.0",
"babel-jest": "^24.8.0",
Expand Down Expand Up @@ -82,8 +84,11 @@
"eslint-plugin-cypress": "^2.11.1",
"formik": "^1.5.8",
"lodash": "^4.17.19",
"plotly.js": "^1.55.2",
"query-string": "^6.8.2",
"react-plotly.js": "^2.4.0",
"react-redux": "^7.1.0",
"react-vis": "^1.11.7",
"reselect": "^4.0.0"
}
}
7 changes: 7 additions & 0 deletions public/models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ export type DetectorListItem = {
enabledTime?: number;
};

export type EntityData = {
name: string;
value: string;
};

export type AnomalyData = {
anomalyGrade: number;
anomalyScore?: number;
Expand All @@ -135,6 +140,8 @@ export type AnomalyData = {
endTime: number;
startTime: number;
plotTime?: number;
entity?: EntityData[];
features?: { [key: string]: FeatureAggregationData };
};

export type FeatureAggregationData = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ import { darkModeEnabled } from '../../../../utils/kibanaUtils';
import {
prepareDataForChart,
getFeatureMissingDataAnnotations,
filterWithDateRange,
} from '../../../utils/anomalyResultUtils';
import { CodeModal } from '../../../DetectorConfig/components/CodeModal/CodeModal';
import { CHART_FIELDS, FEATURE_CHART_THEME } from '../../utils/constants';
import { isEmpty } from 'lodash';

interface FeatureChartProps {
feature: FeatureAttributes;
Expand All @@ -61,6 +63,7 @@ interface FeatureChartProps {
showFeatureMissingDataPointAnnotation?: boolean;
detectorEnabledTime?: number;
rawFeatureData: FeatureAggregationData[];
titlePrefix?: string;
}
const getDisabledChartBackground = () =>
darkModeEnabled() ? '#25262E' : '#F0F0F0';
Expand Down Expand Up @@ -137,12 +140,23 @@ export const FeatureChart = (props: FeatureChartProps) => {
return undefined;
};

const getFeatureAnnotations = () => {
if (isEmpty(props.annotations)) {
return [];
}
return filterWithDateRange(
props.annotations,
props.dateRange,
'coordinates.x0'
);
};
return (
<ContentPanel
title={
props.feature.featureEnabled
(props.titlePrefix ? props.titlePrefix + ' - ' : '') +
(props.feature.featureEnabled
? props.feature.featureName
: `${props.feature.featureName} (disabled)`
: `${props.feature.featureName} (disabled)`)
}
bodyStyles={
!props.feature.featureEnabled
Expand Down Expand Up @@ -172,7 +186,7 @@ export const FeatureChart = (props: FeatureChartProps) => {
/>
{props.feature.featureEnabled ? (
<RectAnnotation
dataValues={props.annotations || []}
dataValues={getFeatureAnnotations()}
id="annotations"
style={{
stroke: darkModeEnabled() ? 'red' : '#D5DBDB',
Expand Down
Loading

0 comments on commit 8829407

Please sign in to comment.