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
actualStart: "15 janvier 2018",
9
actualEnd: "10 mars 2018",
10
children: [
11
{
12
id: "1_1",
13
name: "Analysis",
14
actualStart: "15 janvier 2018",
15
actualEnd: "25 janvier 2018"
16
},
17
{
18
id: "1_2",
19
name: "Design",
20
actualStart: "20 janvier 2018",
21
actualEnd: "4 février 2018"
22
},
23
{
24
id: "1_3",
25
name: "Meeting",
26
actualStart: "5 février 2018",
27
actualEnd: "5 février 2018"
28
},
29
{
30
id: "1_4",
31
name: "Implementation",
32
actualStart: "5 février 2018",
33
actualEnd: "24 février 2018"
34
},
35
{
36
id: "1_5",
37
name: "Testing",
38
actualStart: "25 février 2018",
39
actualEnd: "10 mars 2018"
40
}
41
]}
42
];
43
44
// set the input locale
45
anychart.format.inputLocale("fr-fr");
46
47
// set the input date/time format
48
anychart.format.inputDateTimeFormat("d MMMM yyyy");
49
50
// create a data tree
51
var treeData = anychart.data.tree(data, "as-tree");
52
53
// create a chart
54
var chart = anychart.ganttProject();
55
56
// set the data
57
chart.data(treeData);
58
59
// set the container id
60
chart.container("container");
61
62
// initiate drawing the chart
63
chart.draw();
64
65
// fit elements to the width of the timeline
66
chart.fitAll();
67
});