Skip to content

Commit

Permalink
fix: add conditions to finding min positive and max negative
Browse files Browse the repository at this point in the history
Signed-off-by: Manik Rana <[email protected]>
  • Loading branch information
Maniktherana committed Jun 19, 2024
1 parent 4b77276 commit e9d3ca6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions web/ui/react-app/src/pages/graph/HistogramChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { FC } from 'react';
import { UncontrolledTooltip } from 'reactstrap';
import { Histogram } from '../../types/types';
import { bucketRangeString } from './DataTable';
import { parse } from 'path';

type ScaleType = 'linear' | 'exponential';

Expand Down Expand Up @@ -57,6 +58,14 @@ const HistogramChart: FC<{ histogram: Histogram; index: number; scale: ScaleType
if (parseFloat(buckets[i][1]) > 0) {
return parseFloat(buckets[i][1]);
}
if (parseFloat(buckets[i][1]) < 0 && parseFloat(buckets[i][2]) > 0) {
return parseFloat(buckets[i][2]);
}
if (i === buckets.length - 1) {
if (parseFloat(buckets[i][2]) > 0) {
return parseFloat(buckets[i][2]);
}
}
}
return 0; // all buckets are negative
}
Expand All @@ -68,6 +77,9 @@ const HistogramChart: FC<{ histogram: Histogram; index: number; scale: ScaleType
for (let i = 0; i < buckets.length; i++) {
if (parseFloat(buckets[i][2]) > 0) {
if (i === 0) {
if (parseFloat(buckets[i][1]) < 0) {
return parseFloat(buckets[i][1]); // return the first negative bucket
}
return 0; // all buckets are positive
}
return parseFloat(buckets[i - 1][2]); // return the last negative bucket
Expand Down

0 comments on commit e9d3ca6

Please sign in to comment.