Skip to content

Commit

Permalink
Merge pull request #1443 from oasisprotocol/csillag/hide-nan
Browse files Browse the repository at this point in the history
Avoid showing "NaN%" in the charts when there is no prev data
  • Loading branch information
csillag authored Jun 5, 2024
2 parents 0ec1962 + c2b8fb8 commit f9b0642
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions .changelog/1443.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Avoid showing "NaN%" in the charts when there is no prev data
3 changes: 3 additions & 0 deletions src/app/components/PercentageGain/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ interface PercentageGainProps {
* Negative percentage shows red box with down arrow.
*/
export const PercentageGain: FC<PercentageGainProps> = ({ earliestValue, latestValue }) => {
// If the previous data was zero, we can't divide with it, it would just get us infinity or Nan...
if (earliestValue === 0) return

const ratio = (latestValue - earliestValue) / earliestValue

return (
Expand Down

0 comments on commit f9b0642

Please sign in to comment.