HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// The data used in this sample can be obtained from the CDN
3
// https://cdn.anychart.com/samples/gantt-charts/human-resource-chart/data.js
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/gantt-charts/human-resource-chart/data.json',
6
function (data) {
7
// create data tree
8
var treeData = anychart.data.tree(data, 'as-table');
9
10
// create resource gantt chart
11
var chart = anychart.ganttResource();
12
13
// set data for the chart
14
chart.data(treeData);
15
16
chart
17
.rowSelectedFill('#D4DFE8')
18
.rowHoverFill('#EAEFF3')
19
// set start splitter position settings
20
.splitterPosition(150);
21
22
// get chart data grid link to set column settings
23
var dataGrid = chart.dataGrid();
24
25
// set first column settings
26
dataGrid
27
.column(0)
28
.title('#')
29
.width(30)
30
.labels({ hAlign: 'center' });
31
32
// set second column settings
33
dataGrid.column(1).title('Person').width(120);
34
35
// set container id for the chart
36
chart.container('container');
37
38
// initiate chart drawing
39
chart.draw();
40
41
// zoom chart to specified date
42
chart.zoomTo(1171036800000, 1176908400000);
43
}
44
);
45
});