[Logs UI] Fix alert previews for thresholds of 0 (#111150)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Alejandro Fernández Gómez 2021-09-08 11:33:00 +02:00 committed by GitHub
parent 094f2c9b81
commit 77e25bedfb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 10 deletions

View file

@ -197,14 +197,11 @@ const CriterionPreviewChart: React.FC<ChartProps> = ({
const hasData = series.length > 0;
const { yMin, yMax, xMin, xMax } = getDomain(filteredSeries, isStacked);
const chartDomain = {
max:
showThreshold && threshold && threshold.value
? Math.max(yMax, threshold.value) * 1.1
: yMax * 1.1, // Add 10% headroom.
min: showThreshold && threshold && threshold.value ? Math.min(yMin, threshold.value) : yMin,
max: showThreshold && threshold ? Math.max(yMax, threshold.value) * 1.1 : yMax * 1.1, // Add 10% headroom.
min: showThreshold && threshold ? Math.min(yMin, threshold.value) : yMin,
};
if (showThreshold && threshold && threshold.value && chartDomain.min === threshold.value) {
if (showThreshold && threshold && chartDomain.min === threshold.value) {
chartDomain.min = chartDomain.min * 0.9; // Allow some padding so the threshold annotation has better visibility
}
@ -246,7 +243,7 @@ const CriterionPreviewChart: React.FC<ChartProps> = ({
}}
color={!isGrouped ? colorTransformer(Color.color0) : undefined}
/>
{showThreshold && threshold && threshold.value ? (
{showThreshold && threshold ? (
<LineAnnotation
id={`threshold-line`}
domainType={AnnotationDomainType.YDomain}
@ -260,7 +257,7 @@ const CriterionPreviewChart: React.FC<ChartProps> = ({
}}
/>
) : null}
{showThreshold && threshold && threshold.value && isBelow ? (
{showThreshold && threshold && isBelow ? (
<RectAnnotation
id="below-threshold"
style={{
@ -279,7 +276,7 @@ const CriterionPreviewChart: React.FC<ChartProps> = ({
]}
/>
) : null}
{showThreshold && threshold && threshold.value && isAbove ? (
{showThreshold && threshold && isAbove ? (
<RectAnnotation
id="above-threshold"
style={{

View file

@ -65,7 +65,9 @@ export const Threshold: React.FC<Props> = ({ comparator, value, updateThreshold,
<EuiExpression
description={thresholdPrefix}
uppercase={true}
value={`${comparator ? ComparatorToi18nMap[comparator] : ''} ${value ? value : ''}`}
value={`${comparator ? ComparatorToi18nMap[comparator] : ''} ${
typeof value === 'number' ? value : ''
}`}
isActive={isThresholdPopoverOpen}
onClick={() => setThresholdPopoverOpenState(!isThresholdPopoverOpen)}
/>