|
|
|
@ -79,27 +79,33 @@ export default function ResultContainer() {
|
|
|
|
|
|
|
|
|
|
// Bar Graph handler
|
|
|
|
|
const handlerBarTicks = data => { |
|
|
|
|
const max = Math.ceil(Math.max(...data) / 10) * 10; |
|
|
|
|
const stepSize = handlerStepSize(max); |
|
|
|
|
const max = calculateMax(data); |
|
|
|
|
const stepSize = hadnlerStepSize(max); |
|
|
|
|
|
|
|
|
|
return { max, stepSize }; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const handlerStepSize = max => { |
|
|
|
|
const exponent = Math.floor(Math.log10(max)); |
|
|
|
|
const base = Math.pow(10, exponent); |
|
|
|
|
const calculateMax = data => { |
|
|
|
|
const max = Math.max(...data); |
|
|
|
|
return Math.ceil(max / 5) * 5; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const hadnlerStepSize = max => { |
|
|
|
|
const step = Math.ceil(max / 5); |
|
|
|
|
|
|
|
|
|
let stepSize; |
|
|
|
|
|
|
|
|
|
if (max / base > 5) { |
|
|
|
|
stepSize = base; |
|
|
|
|
} else if (max / (base / 2) > 5) { |
|
|
|
|
stepSize = base / 2; |
|
|
|
|
if (max > 100) { |
|
|
|
|
stepSize = Math.ceil(step / 50) * 50; |
|
|
|
|
} else if (max <= 10) { |
|
|
|
|
stepSize = 1; |
|
|
|
|
} else { |
|
|
|
|
stepSize = base / 5; |
|
|
|
|
stepSize = Math.ceil(step / 5) * 5; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return stepSize; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// 123456789 -> 123,456,789
|
|
|
|
|
const formatNumber = number => { |
|
|
|
|
if (number === 'NoData') return 0; |
|
|
|
|