Skip to content

Commit

Permalink
Merge pull request #139 from openshift-cherrypick-robot/cherry-pick-1…
Browse files Browse the repository at this point in the history
…38-to-release-v1.15.x

[release-v1.15.x] SRVKP-5876: In metrics overview page of tekton results, Average duration chart y-axis is always set to 5m
  • Loading branch information
openshift-merge-bot[bot] authored Jul 29, 2024
2 parents 2a077d4 + cb143d3 commit f9adee6
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 f9adee6

Please sign in to comment.