({ band, data: { value } })
| 3 | import { XCircle } from '@carbonplan/icons' |
| 4 | |
| 5 | const AverageDisplay = ({ band, data: { value } }) => { |
| 6 | if (!value || !value.climate) { |
| 7 | return 'loading...' |
| 8 | } |
| 9 | |
| 10 | let result |
| 11 | const filteredData = value.climate.filter((d) => d !== 9.969209968386869e36) |
| 12 | if (filteredData.length === 0) { |
| 13 | result = 'no data in region' |
| 14 | } else { |
| 15 | const average = |
| 16 | filteredData.reduce((a, b) => a + b, 0) / filteredData.length |
| 17 | if (band === 'prec') { |
| 18 | result = `Average: ${average.toFixed(2)}` |
| 19 | } else { |
| 20 | result = `Average: ${average.toFixed(2)}ºC` |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | return ( |
| 25 | <Box |
| 26 | sx={{ |
| 27 | ml: [2], |
| 28 | mt: ['-1px'], |
| 29 | fontFamily: 'mono', |
| 30 | letterSpacing: 'mono', |
| 31 | textTransform: 'uppercase', |
| 32 | }} |
| 33 | > |
| 34 | {result} |
| 35 | </Box> |
| 36 | ) |
| 37 | } |
| 38 | |
| 39 | const RegionControls = ({ |
| 40 | band, |
nothing calls this directly
no outgoing calls
no test coverage detected