Skip to content

Commit

Permalink
chore: zero axis does not overlap x-axis scale
Browse files Browse the repository at this point in the history
Signed-off-by: Manik Rana <[email protected]>
  • Loading branch information
Maniktherana committed Jun 7, 2024
1 parent a27dd6b commit 29359bc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion web/ui/react-app/src/pages/graph/HistogramChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ const HistogramChart: FC<{ histogram: Histogram; index: number; scale: ScaleType
if (scale === 'linear') {
return ((0 - rangeMin) / (rangeMax - rangeMin)) * 100 + '%';
} else {
if (maxNegative === 0) {
return '0%';
}
if (minPositive === 0) {
return '100%';
}
if (zeroBucketIdx === -1) {
// if there is no zero bucket, we must zero axis between buckets around zero
return (widthNegative / widthTotal) * 100 + '%';
Expand All @@ -94,7 +100,8 @@ const HistogramChart: FC<{ histogram: Histogram; index: number; scale: ScaleType
}
}
function showZeroAxis() {
if (parseFloat(zeroAxisLeft.slice(0, -1)) > 5) {
const axisNumber = parseFloat(zeroAxisLeft.slice(0, -1));
if (5 < axisNumber && axisNumber < 95) {
return true;
}
return false;
Expand Down

0 comments on commit 29359bc

Please sign in to comment.