Browse Source

그래프 max 값 조정

pull/2/head
hhjk00 10 months ago
parent
commit
92b44c8442
  1. 4
      src/components/statistics/StatisticsSearch.js
  2. 25
      src/containers/statistics/AbnormalSituationContainer.js
  3. 26
      src/containers/statistics/FlightContainer.js
  4. 26
      src/containers/statistics/FlightResultContainer.js

4
src/components/statistics/StatisticsSearch.js

@ -62,8 +62,8 @@ export default function StatisticsSearch({
setTotal(totalValue); setTotal(totalValue);
setTop(topValue); setTop(topValue);
} else { } else {
setTotal(filteredData(graphData.map(i => i.value))); setTotal(graph);
setTop(filteredData(topData.map(i => i.value))); setTop(top);
} }
}; };

25
src/containers/statistics/AbnormalSituationContainer.js

@ -80,23 +80,28 @@ export default function AbnormalSituationContainer() {
// Bar Graph handler // Bar Graph handler
const handlerBarTicks = data => { const handlerBarTicks = data => {
const max = Math.ceil(Math.max(...data) / 10) * 10; const max = calculateMax(data);
const stepSize = handlerStepSize(max); const stepSize = hadnlerStepSize(max);
return { max, stepSize }; return { max, stepSize };
}; };
const handlerStepSize = max => { const calculateMax = data => {
const exponent = Math.floor(Math.log10(max)); const max = Math.max(...data);
const base = Math.pow(10, exponent); return Math.ceil(max / 5) * 5;
};
const hadnlerStepSize = max => {
const step = Math.ceil(max / 5);
let stepSize; let stepSize;
if (max / base > 5) { if (max > 100) {
stepSize = base; stepSize = Math.ceil(step / 50) * 50;
} else if (max / (base / 2) > 5) { } else if (max <= 10) {
stepSize = base / 2; stepSize = 1;
} else { } else {
stepSize = base / 5; stepSize = Math.ceil(step / 5) * 5;
} }
return stepSize; return stepSize;

26
src/containers/statistics/FlightContainer.js

@ -79,32 +79,36 @@ export default function FlightContainer() {
// Bar Graph handler // Bar Graph handler
const handlerBarTicks = data => { const handlerBarTicks = data => {
const max = Math.ceil(Math.max(...data) / 10) * 10; const max = calculateMax(data);
const stepSize = handlerStepSize(max); const stepSize = hadnlerStepSize(max);
return { max, stepSize }; return { max, stepSize };
}; };
const handlerStepSize = max => { const calculateMax = data => {
const exponent = Math.floor(Math.log10(max)); const max = Math.max(...data);
const base = Math.pow(10, exponent); return Math.ceil(max / 5) * 5;
};
const hadnlerStepSize = max => {
const step = Math.ceil(max / 5);
let stepSize; let stepSize;
if (searchType.category === 'TIME') { if (searchType.category === 'TIME') {
stepSize = 3600; stepSize = 3600;
} else { } else {
if (max / base > 5) { if (max > 100) {
stepSize = base; stepSize = Math.ceil(step / 50) * 50;
} else if (max / (base / 2) > 5) { } else if (max <= 10) {
stepSize = base / 2; stepSize = 1;
} else { } else {
stepSize = base / 5; stepSize = Math.ceil(step / 5) * 5;
} }
} }
return stepSize; return stepSize;
}; };
// 1234.2345 -> 1,234.2 // 1234.2345 -> 1,234.2
const formatDistance = number => { const formatDistance = number => {
if (number === 'noData' || number === 0.0) return '0'; if (number === 'noData' || number === 0.0) return '0';

26
src/containers/statistics/FlightResultContainer.js

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

Loading…
Cancel
Save