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);
setTop(topValue);
} else {
setTotal(filteredData(graphData.map(i => i.value)));
setTop(filteredData(topData.map(i => i.value)));
setTotal(graph);
setTop(top);
}
};

25
src/containers/statistics/AbnormalSituationContainer.js

@ -80,23 +80,28 @@ export default function AbnormalSituationContainer() {
// 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;

26
src/containers/statistics/FlightContainer.js

@ -79,32 +79,36 @@ export default function FlightContainer() {
// 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 (searchType.category === 'TIME') {
stepSize = 3600;
} else {
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;
};
// 1234.2345 -> 1,234.2
const formatDistance = number => {
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
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;

Loading…
Cancel
Save