Skip to content

Commit

Permalink
Merge pull request #1652 from fedspendingtransparency/bug/contractgra…
Browse files Browse the repository at this point in the history
…ntactivityydomain

Y-Domain Bug Contract Grant Activity
  • Loading branch information
Lizzie Salita authored May 4, 2020
2 parents 6b6b382 + a6c7cad commit 9eb4a12
Showing 1 changed file with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9eb4a12

Please sign in to comment.