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-general-features/multiple-milestones/data.json
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/gantt-general-features/multiple-milestones/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
// set the spliter position
17
chart.splitterPosition(220);
18
19
// set data grid settings
20
var dataGrid = chart.dataGrid();
21
22
var firstColumn = dataGrid.column(0);
23
firstColumn
24
.title('Project\nNumber')
25
.width(80)
26
.labels()
27
.format(function () {
28
return this.item.get('project_number');
29
});
30
firstColumn.title().fontSize(14);
31
32
var secondColumn = dataGrid.column(1);
33
secondColumn.title('Project\nTitle').width(140);
34
secondColumn.title().fontSize(14);
35
secondColumn.labels().textOverflow('...');
36
37
// set container id for the chart
38
chart.container('container');
39
40
// initiate chart drawing
41
chart.draw();
42
43
// zoom chart all dates range
44
chart.fitAll();
45
}
46
);
47
});