diff --git a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.tsx b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.tsx index 7665c4d84e1e..99f5aa972758 100644 --- a/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.tsx +++ b/x-pack/plugins/infra/public/alerting/metric_threshold/components/expression_chart.tsx @@ -12,6 +12,8 @@ import { Settings, TooltipValue, RectAnnotation, + AnnotationDomainTypes, + LineAnnotation, } from '@elastic/charts'; import { first, last } from 'lodash'; import moment from 'moment'; @@ -140,6 +142,7 @@ export const ExpressionChart: React.FC = ({ } const isAbove = [Comparator.GT, Comparator.GT_OR_EQ].includes(expression.comparator); + const isBelow = [Comparator.LT, Comparator.LT_OR_EQ].includes(expression.comparator); const opacity = 0.3; const { timeSize, timeUnit } = expression; const timeLabel = TIME_LABELS[timeUnit]; @@ -149,44 +152,49 @@ export const ExpressionChart: React.FC = ({ - {thresholds.length ? ( - `threshold_${i}`)} - series={series} - stack={false} - opacity={opacity} - /> - ) : null} - {thresholds.length && expression.comparator === Comparator.OUTSIDE_RANGE ? ( + ({ + dataValue: threshold, + }))} + style={{ + line: { + strokeWidth: 2, + stroke: colorTransformer(MetricsExplorerColor.color1), + opacity: 1, + }, + }} + /> + {thresholds.length === 2 && expression.comparator === Comparator.BETWEEN ? ( <> - `threshold_${i}`)} - series={series} - stack={false} - opacity={opacity} + dataValues={[ + { + coordinates: { + x0: firstTimestamp, + x1: lastTimestamp, + y0: first(expression.threshold), + y1: last(expression.threshold), + }, + }, + ]} /> + + ) : null} + {thresholds.length === 2 && expression.comparator === Comparator.OUTSIDE_RANGE ? ( + <> = ({ /> ) : null} + {isBelow && first(expression.threshold) != null ? ( + + ) : null} {isAbove && first(expression.threshold) != null ? (