작업 시간 계산
기본적으로 dhtmlxGantt는 작업 기간을 캘린더 시간으로 계산합니다. 즉, 주말과 공휴일이 전체 기간에 포함됩니다.
자세한 일정 종료일 형식에 대해서는 Task end date display & Inclusive end dates 문서를 참고하세요.
작업 시간 계산 활성화
작업 기간을 근무 시간만 기준으로 계산하려면 work_time에 설명된 옵션을 활성화하세요:
작업 기간에 대해 작업 시간 계산 활성화
gantt.config.work_time = true; // 작업 기간 계산에서 비근무 시간 제외 /*!*/
gantt.config.skip_off_time = true; /*!*/ // 차트에서 비근무 시간 숨김
gantt.init("gantt_here");
skip_off_time 옵션은 PRO 버전에서만 사용할 수 있습니다.
Duration includes only working days
duration_unit 설정에 따라 dhtmlxGantt는 작업 기간을 다양한 단위(예: duration_unit = "hour"인 경우, 근무 시간 기준)로 계산합니다.

소수점 형식의 작업 기간
이 기능은 PRO 에디션에서만 사용할 수 있습니다.
버전 6.3부터 dhtmlxGantt는 Duration Formatter 모듈을 이용해 작업 기간을 소수점 형식("2.5 days",
"0.5 hours", "3.75 hours")으로 지정할 수 있습니다.
내부적으로 Gantt는 작업 기간을 정수 값으로 저장한다는 점에 유의해야 합니다.
formatter 모듈은 사용자가 입력한 소수점 기간을 Gantt가 사용하는 내부 형식으로 변환하는 데 도움을 줍니다(예: 사용자가 "1.5 hours"를 입력하면 90분으로 저장). 또한 저장된 값을 사람이 읽을 수 있는 형식(예: 12시간을 "0.5 days"로 변환)으로 다시 변환합니다.

작업 기간은 duration_unit에서 지원하는 시간, 일 등 다양한 단위의 소수로 표현할 수 있으나, 분(minute) 단위는 제외됩니다.
소수점 형식 구현
작업 기간을 소수점 형식으로 표시하려면 다음 단계를 따르세요:
- duration_unit를 "minute"으로 설정
gantt.config.work_time = true;
gantt.config.duration_unit = "minute"; /*!*/
기간을 저장하는 단위는 소수점으로 표시할 단위보다 더 작아야 합니다. 쉽게 말해:
-
사용자가 시간 단위 소수(예: "0.5 hours")로 입력할 수 있게 하려면 duration_unit를 "minute"으로 설정
-
일 단위 소수를 허용하려면 duration_unit를 "hour"로 설정합니다. 이 경우 사용자는 "0.5 day"와 같이 입력할 수 있지만, "0.5 hour"는 1시간으로 반올림됩니다(기간은 정수 시간 단위로 저장됨).
기본적으로 작업 날짜는 타임스케일에 스냅됩니다. 스케일이 일(day) 단위인 경우, 하루 내에서 시간 단위로 작업을 드래그하려면 이 기능을 비활성화하세요.
이 기능을 사용하려면 round_dnd_dates를 비활성화하고 time_step에 적절한 값을 설정하세요.
예시:
// 전역 타임스텝을 15분으로 설정, duration_unit이 "minute"이어야 함
gantt.config.time_step = 15;
gantt.config.round_dnd_dates = false;
또는
// 전역 타임스텝을 1시간으로 설정,
// duration_unit이 "hour"인 경우에 적합
gantt.config.time_step = 60;
gantt.config.round_dnd_dates = false;
- formatter 객체를 생성하여 기간 포맷을 처리합니다:
// duration formatter 설정
const formatter = gantt.ext.formatters.durationFormatter({
enter: "day",
store: "minute", // duration_unit
format: "day",
hoursPerDay: 8,
hoursPerWeek: 40,
daysPerMonth: 30
});
- "Duration" 열에 formatter를 추가하려면, 포맷된 기간을 반환하는 template 함수를 정의하세요:
gantt.config.columns = [
{ name: "text", tree: true, width: 170, resize: true, editor: textEditor },
{ name: "start_date", align: "center", resize: true, editor: dateEditor },
{ name: "duration", label: "Duration", resize: true, align: "center",
template: task => formatter.format(task.duration), width: 100 },
{ name: "add", width: 44 }
];
- lightbox의 time 컨트롤의 formatter 속성에 formatter를 할당하여 추가합니다:
gantt.config.lightbox.sections = [
{ name: "description", map_to: "text", type: "textarea", height: 70, focus: true },
{ name: "time", map_to: "auto", type: "duration", formatter: formatter }
];
- 그리드에서 인라인 편집이 활성화된 경우, durationEditor 객체의 formatter 속성에도 formatter를 추가하세요:
const durationEditor = {
type: "duration",
map_to: "duration",
formatter: formatter, /*!*/
min: 0,
max: 1000
};
gantt.config.columns = [
{ name: "text", tree: true, width: 170, resize: true },
{ name: "start_date", align: "center", resize: true },
{ name: "duration", label: "Duration", resize: true, align: "center",
template: (task) => formatter.format(task.duration),
editor: durationEditor, width: 100 },
{ name: "add", width: 44 }
];
이미 Gantt에서 작업 기간을 분, 시간 또는 다른 단위로 저장하고 있다면, Duration Formatter 모듈을 사용해 소수점 형식으로 표시할 수 있습니다.