This PR addresses overaggressive rounding in charts where we calculate the decadal mean from yearly values client-side. Look at the hovertext in the screenshot below to see what I mean:
Since the mean is rounded to a whole number, 0, it ends up being larger than the max number. And because of this, the plot marker is placed above/outside of the error bars.
To solve this, I've created a new utility function, precisionMean, that calculates the difference between the min/max values and rounds the mean to 1 decimal of precision if the difference is less than 10. If the difference is greater than (or equal to) 10, it continues to round to a whole number.
Here's a screenshot of the same chart using the new precisionMean function:
To test, run the webapp against Zeus:
export RASDAMAN_URL=https://zeus.snap.uaf.edu/rasdaman/ows
export SNAP_API_URL=http://development.earthmaps.io
npm run dev
Then look at the charts for a few of the affected ARDAC items below and make sure the mean rounding in the hovertext is what you'd expect:
Closes #65.
This PR addresses overaggressive rounding in charts where we calculate the decadal mean from yearly values client-side. Look at the hovertext in the screenshot below to see what I mean:
Since the mean is rounded to a whole number,
0
, it ends up being larger than the max number. And because of this, the plot marker is placed above/outside of the error bars.To solve this, I've created a new utility function,
precisionMean
, that calculates the difference between the min/max values and rounds the mean to 1 decimal of precision if the difference is less than 10. If the difference is greater than (or equal to) 10, it continues to round to a whole number.Here's a screenshot of the same chart using the new
precisionMean
function:To test, run the webapp against Zeus:
Then look at the charts for a few of the affected ARDAC items below and make sure the mean rounding in the hovertext is what you'd expect:
http://localhost:3000/item/dd-below-65 http://localhost:3000/item/dd-below-0 http://localhost:3000/item/thawing-index http://localhost:3000/item/freezing-index http://localhost:3000/item/wet-days-per-year http://localhost:3000/item/permafrost-magt http://localhost:3000/item/permafrost-base-top http://localhost:3000/item/permafrost-talik http://localhost:3000/item/indicator-ftc-cmip6 http://localhost:3000/item/indicator-su-cmip6 http://localhost:3000/item/indicator-dw-cmip6 http://localhost:3000/item/indicator-rx1day-cmip6