리소스 관리
이 기능은 Gantt PRO 에디션에만 포함되어 있습니다.
Gantt는 리소스 부하를 시각화할 수 있는 사전 정의된 리소스 뷰, 작업별로 프로젝트를 분해하여 작업 부하를 균형 있게 조정할 수 있는 도구, 그리고 작업 및 리소스에 맞춤화된 캘린더를 제공합니다.

Gantt 자체적으로 리소스 부하를 계산하거나 내장된 방법을 제공하지는 않지만, 필요한 모든 맞춤 기능을 생성할 수 있도록 public API를 제공합니다.
리소스 뷰 패널
dhtmlxGantt는 리소스 부하를 표시하기 위해 두 가지 사전 정의된 레이아웃 뷰를 제공합니다: 리소스 부하 다이어그램과 리소스 히스토그램입니다.
리소스 부하 다이어그램
이 다이어그램에는 "resourceGrid"와 "resourceTimeline"이라는 그리드와 타임라인 전용 뷰가 포함되어 있습니다.

gantt.config.layout = {
css: "gantt_container",
rows: [
{
// 기본 Grid 및 Timeline 레이아웃
cols: [
{view: "grid", group:"grids", scrollY: "scrollVer"},
{resizer: true, width: 1},
{view: "timeline", scrollX: "scrollHor", scrollY: "scrollVer"},
{view: "scrollbar", id: "scrollVer", group:"vertical"}
],
gravity:2
},
{ resizer: true, width: 1},
{
// 리소스 패널의 Grid 및 Timeline 레이아웃
config: resourceConfig, // Grid 및 Timeline용 config
cols: [
{view: "resourceGrid", group:"grids", width: 435, scrollY:"resourceVScroll"},
{resizer: true, width: 1},
{view: "resourceTimeline", scrollX: "scrollHor", scrollY:"resourceVScroll"},
{view: "scrollbar", id: "resourceVScroll", group:"vertical"}
],
gravity:1
},
{view: "scrollbar", id: "scrollHor"}
]
};
설정 후 resourceGrid는 기본 grid 뷰처럼 동작하지만 읽기 전용입니다. resourceTimeline은 기본 타임라인과 동일한 스케일 설정을 사용하며, 두 개의 레이어가 있습니다:
- 배경 행: task_row_class 및 timeline_cell_class에서 제공하는 템플릿을 사용합니다. 이들은 레이아웃 수준에서 사용자 정의할 수 있습니다.
- 리소스 레이어: resourceTimeline에만 존재하며, 리소스가 할당된 작업이 있는 셀에 블록을 보여줍니다. 이 블록의 스타일과 내용은 resource_cell_class 및 resource_cell_value 템플릿으로 사용자 정의할 수 있습니다.
gantt.templates.resource_cell_value = function(start_date, end_date, resource, tasks,
assignments){
var html = "<div>" + tasks.length * 8 + "h</div>";
return html;
};
Templates of the Resource diagram
리소스 히스토그램
이 리소스 부하 레이아웃 뷰는 그리드와 타임라인에 각각 "resourceGrid"와 "resourceHistogram" 뷰를 포함합니다.

gantt.config.layout = {
css: "gantt_container",
rows: [
{
// 기본 Grid 및 Timeline 레이아웃
gravity: 2,
cols: [
{view: "grid", group:"grids", scrollY: "scrollVer"},
{resizer: true, width: 1},
{view: "timeline", scrollX: "scrollHor", scrollY: "scrollVer"},
{view: "scrollbar", id: "scrollVer", group:"vertical"}
]
},
{ resizer: true, width: 1, next: "resources"},
{
// 리소스 패널의 Grid 및 Timeline 레이아웃
gravity:1,
id: "resources",
config: resourceConfig, // Grid 및 Timeline용 config
templates: resourceTemplates, // Grid 및 Timeline용 templates
cols: [
{ view: "resourceGrid", group:"grids", scrollY: "resourceVScroll" },
{ resizer: true, width: 1},
{ view: "resourceHistogram", capacity:24, scrollX: "scrollHor",
scrollY: "resourceVScroll"},
{ view: "scrollbar", id: "resourceVScroll", group:"vertical"}
]
},
{view: "scrollbar", id: "scrollHor"}
]
};
리소스 부하 다이어그램과 마찬가지로 resourceGrid는 기본 grid 뷰와 유사하게 동작하지만 읽기 전용입니다. resourceHistogram은 여러 추가 템플릿을 제공합니다:
- histogram_cell_class - 리소스 패널 셀에 적용되는 CSS 클래스
gantt.templates.histogram_cell_class="function(start_date,end_date,resource,tasks,"
assignments){
return "";
};
- histogram_cell_label - 셀 내부에 표시되는 라벨
gantt.templates.histogram_cell_label="function(start_date,end_date,resource,tasks,"
assignments){
return tasks.length * 8;
};
- histogram_cell_allocated - 히스토그램에서 채워진 영역의 높이 (0 ~ maxCapacity)
gantt.templates.histogram_cell_allocated="function(start_date,end_date,resource,tasks,"
assignments){
return tasks.length * 8;
};
- histogram_cell_capacity - 리소스의 사용 가능 용량을 나타내는 선의 높이 (-1 ~ maxCapacity, 0 미만이면 선이 숨겨짐)
gantt.templates.histogram_cell_capacity="function(start_date,end_date,resource,tasks,"
assignments){
return 24;
};
maxCapacity 이해하기
각 히스토그램 행은 막대그래프처럼 작동하며, maxCapacity는 Y축의 스케일 높이를 의미합니다. 아래 예시에서 maxCapacity는 24입니다.

따라서 histogram_cell_allocated 또는 histogram_cell_capacity를 24로 설정하면 행의 맨 위에 도달합니다.
기본적으로 maxCapacity는 모든 리소스에 대해 24로 설정되어 있습니다. histogram_cell_capacity에서 24보다 큰 값을 반환해도 계산은 올바르게 처리되지만, 리소스 패널 셀에서 채워진 영역이 예상과 다르게 보일 수 있습니다.

maxCapacity는 전체 히스토 그램 또는 리소스별로 개별적으로 설정할 수 있습니다. 예시는 다음과 같습니다:
Related example: maxCapacity 설정 예시
maxCapacity는 히스토그램 수준에서 설정할 수 있습니다:
{ view: "resourceHistogram", capacity:24, scrollX: "scrollHor",
scrollY: "resourceVScroll"}
또는 각 리소스별로 개별 지정할 수 있습니다:
resourcesStore.parse([
{id: 1, text: "John", capacity:8},
{id: 2, text: "Mike", capacity:4},
{id: 3, text: "Anna", capacity:8},
{id: 4, text: "Bill", capacity:8},
{id: 5, text: "Floe", capacity:8}
]);
리소스별로 설정된 capacity는 해당 리소스에 대해 히스토그램의 전역 capacity를 덮어씁니다.
리소스 뷰 패널 사용하기
기본적으로 두 뷰("resourceGrid"와 "resourceTimeline" 또는 "resourceGrid"와 "resourceHistogram") 모두 gantt.config.resource_store 설정에서 지정한 데이터 스토어와 연결됩니다.
데이터 스토어 자동 생성
v8.0부터 리소스 데이터 스토어는 gantt가 초기화될 때 자동으로 생성되며, "onGanttReady" 이벤트가 발생할 때까지 준비됩니다. 이 스토어에 접근하려면 getDatastore 메서드를 사용하세요.
리소스 스토어를 사용자 정의하려면 gantt.config.resources 옵션을 사용할 수 있습니다:
gantt.config.resources = {
resource_store: {
type: "treeDataStore",
fetchTasks: true,
initItem: function(item) {
item.parent = item.parent || gantt.config.root_id;
item[gantt.config.resource_property] = item.parent;
item.open = true;
return item;
}
},
}
resource_store 내부의 설정은 기본 리소스 데이터스토어를 생성하는 데 사용됩니다. 이미 코드에 리소스 데이터스토어가 있다면 gantt는 기존 스토어를 사용합니다.
리소스를 로드하려면, 여기에서 설명한 대로 gantt.parse()/**gantt.load()**를 사용하거나, **datastore.parse()**를 통해 직접 데이터스토어를 채울 수 있습니다:
gantt.attachEvent("onGanttReady", function(){
const store = gantt.getDatastore(gantt.config.resource_store);
store.parse([
{id: 6, text: "John"},
{id: 7, text: "Mike"},
{id: 8, text: "Anna"},
{id: 9, text: "Bill"},
])
});
라이트박스의 리소스 컨트롤은 자동으로 리소스 목록에 연결됩니다:
gantt.config.lightbox = {
sections: [
...,
{ name: "resources", type: "resources", map_to: "auto", default_value: 8}
]
};
데이터 스토어 수동 생성
createDatastore 메서드를 사용하여 데이터 스토어를 수동으로 생성할 수도 있습니다:
var resourcesStore = gantt.createDatastore({
name: gantt.config.resource_store,
// 리소스가 계층적(예: 직원/부서)인 경우 treeDatastore 사용,
// 평면 구조라면 "type" 생략
type: "treeDatastore",
initItem: function (item) {
item.parent = item.parent || gantt.config.root_id;
item[gantt.config.resource_property] = item.parent;
item.open = true;
return item;
}
});
데이터 스토어를 채우려면 datastore.parse 메서드를 사용하세요:
resourcesStore.parse([
{id: 1, text: "QA", parent:null},
{id: 2, text: "Development", parent:null},
{id: 3, text: "Sales", parent:null},
{id: 4, text: "Other", parent:null},
{id: 5, text: "Unassigned", parent:4},
{id: 6, text: "John", parent:1},
{id: 7, text: "Mike", parent:2},
{id: 8, text: "Anna", parent:2},
{id: 9, text: "Bill", parent:3},
{id: 10, text: "Floe", parent:3}
]);
라이트박스에서 리소스를 사용하려면, 데이터 스토어의 onParse 이벤트에서 serverList 메서드를 통해 다음과 같이 처리하는 것이 유용합니다:
resourcesStore.attachEvent("onParse", function(){
var people = [];
resourcesStore.eachItem(function(res){
if(!resourcesStore.hasChild(res.id)){
var copy = gantt.copy(res);
copy.key = res.id;
copy.label = res.text;
people.push(copy);
}
});
gantt.updateCollection("resourceOptions", people);
});