Skip to content

Commit

Permalink
[Logs UI] Fix alert previews for thresholds of 0 (#111150)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
Alejandro Fernández Gómez and kibanamachine authored Sep 8, 2021
1 parent 094f2c9 commit 77e25be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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}
Expand All @@ -260,7 +257,7 @@ const CriterionPreviewChart: React.FC<ChartProps> = ({
}}
/>
) : null}
{showThreshold && threshold && threshold.value && isBelow ? (
{showThreshold && threshold && isBelow ? (
<RectAnnotation
id="below-threshold"
style={{
Expand All @@ -279,7 +276,7 @@ const CriterionPreviewChart: React.FC<ChartProps> = ({
]}
/>
) : null}
{showThreshold && threshold && threshold.value && isAbove ? (
{showThreshold && threshold && isAbove ? (
<RectAnnotation
id="above-threshold"
style={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
/>
Expand Down

0 comments on commit 77e25be

Please sign in to comment.