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
actualStart: "2018-01-15",
19
actualEnd: "2018-01-25",
20
progressValue: "75%"
21
},
22
{
23
id: "1_2",
24
name: "Design",
25
baselineStart: "2018-01-20",
26
baselineEnd: "2018-01-31",
27
actualStart: "2018-01-20",
28
actualEnd: "2018-02-04",
29
progressValue: "80%"
30
},
31
{
32
id: "1_3",
33
name: "Meeting",
34
actualStart: "2018-02-05",
35
actualEnd: "2018-02-05"
36
},
37
{
38
id: "1_4",
39
name: "Implementation",
40
baselineStart: "2018-02-01",
41
baselineEnd: "2018-02-19",
42
actualStart: "2018-02-05",
43
actualEnd: "2018-02-24",
44
progressValue: "60%"
45
},
46
{
47
id: "1_5",
48
name: "Testing",
49
baselineStart: "2018-02-20",
50
baselineEnd: "2018-03-05",
51
actualStart: "2018-02-25",
52
actualEnd: "2018-03-10",
53
progressValue: "20%"
54
}
55
]}
56
];
57
58
// create a data tree
59
var treeData = anychart.data.tree(data, "as-tree");
60
61
// create a chart
62
var chart = anychart.ganttProject();
63
64
// set the data
65
chart.data(treeData);
66
67
// configure the scale
68
chart.getTimeline().scale().maximum("2018-03-13");
69
70
// set the row height
71
chart.defaultRowHeight(35);
72
73
// set the header height
74
chart.headerHeight(105);
75
76
// disable timeline tooltips
77
chart.getTimeline().tooltip(false);
78
79
// disable labels of timeline elements
80
chart.getTimeline().elements().labels(false);
81
82
// allow editing the chart
83
chart.edit(true);
84
85
// access the timeline and timeline elements
86
var timeline = chart.getTimeline();
87
var elements = timeline.elements();
88
89
// configure duration thumbs
90
elements.edit().thumbs().size(10);
91
elements.edit().thumbs().stroke("#dd2c00", 2);
92
elements.edit().thumbs().fill("#00bfa5");
93
94
// configure connector thumbs
95
elements.edit().connectorThumbs().size(15);
96
elements.edit().connectorThumbs().fill("#dd2c00");
97
elements.edit().connectorThumbs().stroke("#dd2c00", 2);
98
99
// configure connector thumbs on the right
100
elements.edit().end().connectorThumb().type("triangleRight");
101
elements.edit().end().connectorThumb().horizontalOffset(-1);
102
103
// configure connector thumbs on the left
104
elements.edit().start().connectorThumb().type("triangleLeft");
105
elements.edit().start().connectorThumb().horizontalOffset(1);
106
107
// configure sliders of progress bars
108
timeline.tasks().progress().edit().fill("#00bfa5");
109
timeline.tasks().progress().edit().stroke("#dd2c00", 2);
110
111
// set the container id
112
chart.container("container");
113
114
// initiate drawing the chart
115
chart.draw();
116
117
// fit elements to the width of the timeline
118
chart.fitAll();
119
});