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
// create data
4
var data = [
5
{
6
id: "1",
7
name: "Development",
8
baselineStart: "2018-01-12",
9
baselineEnd: "2018-03-04",
10
actualStart: "2018-01-15",
11
actualEnd: "2018-03-10",
12
children: [
13
{
14
id: "1_1",
15
name: "Analysis",
16
baselineStart: "2018-01-12",
17
baselineEnd: "2018-01-25",
18
baseline: {fill: "#dd2c00 0.3", stroke: "0.5 #dd2c00"},
19
actualStart: "2018-01-15",
20
actualEnd: "2018-01-25",
21
actual: {fill: "#dd2c00", stroke: "0.5 #dd2c00"},
22
progressValue: "75%",
23
progress: {fill: "#455a64 0.5", stroke: "0.5 #dd2c00"},
24
connectTo: "1_2",
25
connectorType: "finish-finish",
26
connector: {fill: "#dd2c00", stroke: "2 #dd2c00"}
27
},
28
{
29
id: "1_2",
30
name: "Design",
31
baselineStart: "2018-01-20",
32
baselineEnd: "2018-01-31",
33
actualStart: "2018-01-20",
34
actualEnd: "2018-02-04",
35
progressValue: "100%",
36
connectTo: "1_4",
37
connectorType: "start-start"
38
},
39
{
40
id: "1_3",
41
name: "Meeting",
42
actualStart: "2018-02-05",
43
actualEnd: "2018-02-05"
44
},
45
{
46
id: "1_4",
47
name: "Implementation",
48
baselineStart: "2018-02-01",
49
baselineEnd: "2018-02-19",
50
actualStart: "2018-02-05",
51
actualEnd: "2018-02-24",
52
progressValue: "60%"
53
},
54
{
55
id: "1_5",
56
name: "Testing",
57
baselineStart: "2018-02-20",
58
baselineEnd: "2018-03-05",
59
actualStart: "2018-02-25",
60
actualEnd: "2018-03-10"
61
}
62
]}
63
];
64
65
// create a data tree
66
var treeData = anychart.data.tree(data, "as-tree");
67
68
// create a chart
69
var chart = anychart.ganttProject();
70
71
// set the data
72
chart.data(treeData);
73
74
// disable labels of tasks and parent tasks
75
chart.getTimeline().tasks().labels(false);
76
chart.getTimeline().groupingTasks().labels(false);
77
78
// set the container id
79
chart.container("container");
80
81
// initiate drawing the chart
82
chart.draw();
83
84
// fit elements to the width of the timeline
85
chart.fitAll();
86
});