Skip to content

Commit f9b0642

Browse files
authored
Merge pull request #1443 from oasisprotocol/csillag/hide-nan
Avoid showing "NaN%" in the charts when there is no prev data
2 parents 0ec1962 + c2b8fb8 commit f9b0642

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

.changelog/1443.trivial.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Avoid showing "NaN%" in the charts when there is no prev data

src/app/components/PercentageGain/index.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ interface PercentageGainProps {
1313
* Negative percentage shows red box with down arrow.
1414
*/
1515
export const PercentageGain: FC<PercentageGainProps> = ({ earliestValue, latestValue }) => {
16+
// If the previous data was zero, we can't divide with it, it would just get us infinity or Nan...
17+
if (earliestValue === 0) return
18+
1619
const ratio = (latestValue - earliestValue) / earliestValue
1720

1821
return (

0 commit comments

Comments
 (0)