Skip to content

Commit

Permalink
Corrected y-axis value in average duration chart
Browse files Browse the repository at this point in the history
  • Loading branch information
lokanandaprabhu authored and openshift-cherrypick-robot committed Jul 26, 2024
1 parent 2a077d4 commit cb143d3
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/pipelines-metrics/PipelinesAverageDuration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,15 @@ const PipelinesAverageDuration: React.FC<PipelinesAverageDurationProps> = ({
break;
}

const max = Math.max(...chartData.map((yVal) => yVal.y));
const roundUp = (value, nearest) => {
return Math.ceil(value / nearest) * nearest;
};
const nearest = max > 10 ? 10 : 5;
const roundedMax = roundUp(max, nearest);
domainValue.y =
!isNaN(roundedMax) && roundedMax > 5 ? [0, roundedMax] : [0, 5];

if (!domainY) {
let minY: number = _.minBy(chartData, 'y')?.y ?? 0;
let maxY: number = _.maxBy(chartData, 'y')?.y ?? 0;
Expand Down

0 comments on commit cb143d3

Please sign in to comment.