qltyDataSetting common index 로 이동
This commit is contained in:
@@ -214,6 +214,17 @@ export const roundUp = (value: number, precision: number = 1): number => {
|
||||
return Math.round(value * (10 ** precision)) / (10 ** precision);
|
||||
}
|
||||
|
||||
/**
|
||||
* 수질 데이터 포맷 변경 함수
|
||||
* @param value : 수질 데이터
|
||||
* @param day : 일수
|
||||
* @param digit : 소수점 자리수
|
||||
*/
|
||||
export const qltyDataSetting = (value: number, day : number, digit: number) => {
|
||||
const toZero = digit === 1 ? '0.0' : digit === 2 ? '0.00' : '0.000';
|
||||
return value > 0 ? roundUp((value/day), digit).toFixed(digit) : toZero;
|
||||
};
|
||||
|
||||
/**
|
||||
* STORE - API
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
import { getFetch } from "@/app/components/api";
|
||||
import CalcRainEffect from "@/app/components/common/CalcRainEffect";
|
||||
import DataForm from "@/app/components/common/DataForm";
|
||||
import { fetchPlanInfo, OSU_PERCENT, roundUp } from "../common";
|
||||
import { fetchPlanInfo, OSU_PERCENT, qltyDataSetting, roundUp } from "../common";
|
||||
import type { FacilityWaterQltyProps } from "../facilityWaterQlty";
|
||||
import { fetchFlowRateModalList } from "../flowRate";
|
||||
|
||||
@@ -735,11 +735,6 @@ const fetchMainGraph = async (searchYear: string|undefined, fcltyCd: string|unde
|
||||
|
||||
// 수질 데이터 청천시, 강우시 재계산
|
||||
const calcWaterQltyData = async (data: any[], searchYear : string|undefined, fcltyCd : string|undefined) => {
|
||||
// 데이터 결과값 dataFormat 가공
|
||||
const qltyDataSetting = (value: number, day : number, digit: number) => {
|
||||
const toZero = digit === 1 ? '0.0' : digit === 2 ? '0.00' : '0.000';
|
||||
return value > 0 ? roundUp((value/day), digit).toFixed(digit) : toZero;
|
||||
};
|
||||
|
||||
const orgData = data;
|
||||
const res = await fetchMainGraph(searchYear, fcltyCd);
|
||||
|
||||
Reference in New Issue
Block a user