mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[ML] Fixes Single Metric Viewer anomaly markers for long chart aggregation (#34791)
This commit is contained in:
parent
962722ae8a
commit
d259e1f258
2 changed files with 13 additions and 6 deletions
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue