diff --git a/src/js/components/award/shared/activity/ContractGrantActivityChart.jsx b/src/js/components/award/shared/activity/ContractGrantActivityChart.jsx index 9dfa8f44c6..b1d78c3394 100644 --- a/src/js/components/award/shared/activity/ContractGrantActivityChart.jsx +++ b/src/js/components/award/shared/activity/ContractGrantActivityChart.jsx @@ -87,15 +87,17 @@ const ContractGrantsActivityChart = ({ const clonedTransactions = cloneDeep(transactions); clonedTransactions.sort( (a, b) => a.running_obligation_total - b.running_obligation_total); - const yZero = clonedTransactions.length > 1 ? - clonedTransactions[0].running_obligation_total : - 0; - let yOne = !clonedTransactions.length ? - 0 : - totalObligation || clonedTransactions.pop().running_obligation_total; - // if any transaction is greater than the obligation - const transactionIsGreaterThanObligation = clonedTransactions.find((t) => t.running_obligation_total > totalObligation); - if (transactionIsGreaterThanObligation) yOne = transactionIsGreaterThanObligation.running_obligation_total; + const yZero = 0; + let yOne = 0; + if (clonedTransactions.length > 1) { // multiple transactions + // if the total obligation if bigger than any running obligation total, use total obligation + yOne = totalObligation > clonedTransactions[clonedTransactions.length - 1].running_obligation_total + ? totalObligation + : clonedTransactions[clonedTransactions.length - 1].running_obligation_total; + } + else { // one transaction + yOne = totalObligation || clonedTransactions[0]; + } setYDomain([yZero, yOne]); }, [transactions, totalObligation]); // hook - runs only on mount unless transactions change