From 1f797309a6272afe70748a04bcf2c7c4bea5c096 Mon Sep 17 00:00:00 2001 From: James Grugett Date: Mon, 12 Sep 2022 00:19:41 -0500 Subject: [PATCH] Prob change table shows variable number of rows --- web/components/contract/prob-change-table.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/web/components/contract/prob-change-table.tsx b/web/components/contract/prob-change-table.tsx index 5a616f14..49216b88 100644 --- a/web/components/contract/prob-change-table.tsx +++ b/web/components/contract/prob-change-table.tsx @@ -17,16 +17,20 @@ export function ProbChangeTable(props: { if (!changes) return const { positiveChanges, negativeChanges } = changes - if (positiveChanges.length === 0 && negativeChanges.length === 0) return null - const rows = Math.min( - Math.min(positiveChanges.length, negativeChanges.length), - 3 + const threshold = 0.075 + const countOverThreshold = Math.max( + positiveChanges.findIndex((c) => c.probChanges.day < threshold) + 1, + negativeChanges.findIndex((c) => c.probChanges.day > -threshold) + 1 ) + const maxRows = Math.min(positiveChanges.length, negativeChanges.length) + const rows = Math.min(3, Math.min(maxRows, countOverThreshold)) const filteredPositiveChanges = positiveChanges.slice(0, rows) const filteredNegativeChanges = negativeChanges.slice(0, rows) + if (rows === 0) return
None
+ return (