HTMLcopy
1
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function(){
2
3
// data tree settings
4
var treeData = anychart.data.tree(data, anychart.enums.TreeFillingMethod.AS_TABLE);
5
6
// chart type
7
var chart = anychart.ganttResource();
8
9
// chart container
10
chart.container("container");
11
12
// chart position
13
chart.bounds(0, 0, "100%", "100%");
14
15
// chart data
16
chart.data(treeData);
17
18
// data tree width
19
chart.splitterPosition(170);
20
21
var dataGrid = chart.dataGrid();
22
23
// settings for first column
24
dataGrid.column(0).width(30).title().text("#");
25
26
// settings for the second column
27
dataGrid.column(1).width(140).format(function(item) {
28
return item.get("name");
29
}).title().text("Person");
30
31
// initiate drawing
32
chart.draw();
33
34
// area to display by default
35
chart.zoomTo(1171036800000, 1176908400000);
36
});
37
38
// data
39
var data = [
40
{
41
"id": "1",
42
"name": "Phase 1 - Strategic Plan",
43
"periods": [
44
{"id": "1_1", "start": 1171468800000, "end": 1171987200000, "fill": "green"}]
45
},
46
{
47
"id": "2",
48
"name": "Self-Assessment",
49
"periods": [
50
{"id": "2_1", "start": 1173024000000, "end": 1173715200000, "fill": "yellow"}]
51
},
52
{
53
"id": "3",
54
"name": "Define business vision",
55
"periods": [
56
{"id": "3_1", "start": 1169740800000, "end": 1170172800000, "fill": "green"}]
57
},
58
{
59
"id": "4",
60
"name": "Identify available skills, information and support",
61
"periods": [
62
{"id": "4_1", "start": 1171814400000, "end": 1172419200000, "fill": "green"}]
63
},
64
{
65
"id": "5",
66
"name": "Decide whether to proceed",
67
"periods": [
68
{"id": "5_1", "start": 1171296000000, "end": 1171382400000, "fill": "green"}]
69
},
70
{
71
"id": "6",
72
"name": "Define the Opportunity",
73
"periods": [
74
{"id": "6_1", "start": 1173628800000, "end": 1174320000000, "fill": "green"}]
75
}
76
];