oasisprotocol / explorer

Official explorer for the Oasis Network.
https://explorer.oasis.io
Apache License 2.0
8 stars 7 forks source link

Avoid showing "NaN%" in the charts when there is no prev data #1443

Closed csillag closed 3 months ago

csillag commented 3 months ago

We have some statistics up on the paratime dashboards. However, when comparing to the current data to the previous one (whatever that means for the current setting), if the previous one was 0, when calculating the change, we get a division by zero error, and hence, NaN.

As discussed with @donouwens , in these situations, we should simply hide the percentage value. Like this:

Before: After:
image image
github-actions[bot] commented 3 months ago

Deployed to Cloudflare Pages

Latest commit: c2b8fb84c165963cd0d32e5247fbbc57e6659b0c
Status:✅ Deploy successful!
Preview URL: https://5173aa07.oasis-explorer.pages.dev
csillag commented 3 months ago

Wait this doesn't work like I thought. If it was division by zero it would print Infinity, not NaN

1/0 is infinity, but 0/0 is NaN. Bottom line, we just shouldn't divide by zero.