[ML] Fixes Single Metric Viewer anomaly markers for long chart aggregation (#34791)

This commit is contained in:
Pete Harverson 2019-04-09 17:04:42 +01:00 committed by GitHub
parent 962722ae8a
commit d259e1f258
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 6 deletions

View file

@ -420,7 +420,8 @@ module.controller('MlTimeSeriesExplorerController', function (
refreshFocusData.focusChartData,
refreshFocusData.anomalyRecords,
$scope.timeFieldName,
$scope.focusAggregationInterval);
$scope.focusAggregationInterval,
$scope.modelPlotEnabled);
refreshFocusData.focusChartData = processScheduledEventsForChart(
refreshFocusData.focusChartData,

View file

@ -98,7 +98,8 @@ export function processDataForFocusAnomalies(
chartData,
anomalyRecords,
timeFieldName,
aggregationInterval) {
aggregationInterval,
modelPlotEnabled) {
const timesToAddPointsFor = [];
@ -122,10 +123,16 @@ export function processDataForFocusAnomalies(
timesToAddPointsFor.sort((a, b) => a - b);
timesToAddPointsFor.forEach((time) => {
chartData.push({
const pointToAdd = {
date: new Date(time),
value: null
});
};
if (modelPlotEnabled === true) {
pointToAdd.upper = null;
pointToAdd.lower = null;
}
chartData.push(pointToAdd);
});
// Iterate through the anomaly records adding the
@ -257,10 +264,9 @@ export function findChartPointForAnomalyTime(chartData, anomalyTime, aggregation
// which contains the anomalous bucket.
let foundItem;
const intervalMs = aggregationInterval.asMilliseconds();
const anomalyTimeForAggInt = (Math.floor(anomalyTime / intervalMs)) * intervalMs;
for (let i = 0; i < chartData.length; i++) {
const itemTime = chartData[i].date.getTime();
if (itemTime === anomalyTimeForAggInt) {
if (anomalyTime - itemTime < intervalMs) {
foundItem = chartData[i];
break;
}