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: "2018-01-15",
9
actualEnd: "2018-03-10",
10
markers: [
11
{value: "2018-01-18", type: "cross"},
12
{value: "2018-02-02", type: "circle"},
13
{value: "2018-02-05", type: "diamond", fill: "#ffa000"},
14
{value: "2018-03-01", type: "diagonal-cross"},
15
{value: "2018-03-06", type: "diagonal-cross"}
16
],
17
children: [
18
{
19
id: "1_1",
20
name: "Analysis",
21
actualStart: "2018-01-15",
22
actualEnd: "2018-01-25"
23
},
24
{
25
id: "1_2",
26
name: "Design",
27
actualStart: "2018-01-20",
28
actualEnd: "2018-02-04",
29
markers: [
30
{value: "2018-01-18", type: "cross"}
31
]},
32
{
33
id: "1_3",
34
name: "Meeting",
35
actualStart: "2018-02-05",
36
actualEnd: "2018-02-05",
37
markers: [
38
{value: "2018-02-02", type: "circle"},
39
]},
40
{
41
id: "1_4",
42
name: "Implementation",
43
actualStart: "2018-02-05",
44
actualEnd: "2018-02-24"
45
},
46
{
47
id: "1_5",
48
name: "Testing",
49
actualStart: "2018-02-25",
50
actualEnd: "2018-03-10",
51
markers: [
52
{value: "2018-03-01", type: "diagonal-cross"},
53
{value: "2018-03-06", type: "diagonal-cross"}
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 markers
68
chart.getTimeline().markers().fill("#dd2c00");
69
chart.getTimeline().markers().stroke("black");
70
71
// configure the scale
72
chart.getTimeline().scale().maximum("2018-03-15");
73
74
// set the container id
75
chart.container("container");
76
77
// initiate drawing the chart
78
chart.draw();
79
80
// fit elements to the width of the timeline
81
chart.fitAll();
82
});