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-25",
9
actualEnd: "2018-03-10",
10
children: [
11
{
12
id: "1_2",
13
name: "Analysis",
14
actualStart: "2018-01-25",
15
actualEnd: "2018-02-08"
16
},
17
{
18
id: "1_3",
19
name: "Design",
20
actualStart: "2018-02-04",
21
actualEnd: "2018-02-14"
22
},
23
{
24
id: "1_4",
25
name: "Meeting",
26
actualStart: "2018-02-15",
27
actualEnd: "2018-02-15"
28
},
29
{
30
id: "1_5",
31
name: "Implementation",
32
actualStart: "2018-02-15",
33
actualEnd: "2018-02-27"
34
},
35
{
36
id: "1_6",
37
name: "Testing",
38
actualStart: "2018-02-28",
39
actualEnd: "2018-03-10"
40
}
41
]},
42
{
43
id: "2",
44
name: "PR Campaign",
45
actualStart: "2018-02-15",
46
actualEnd: "2018-03-22",
47
children: [
48
{
49
id: "2_1",
50
name: "Planning",
51
actualStart: "2018-02-15",
52
actualEnd: "2018-03-10"
53
},
54
{
55
id: "2_2",
56
name: "Promoting",
57
actualStart: "2018-03-11",
58
actualEnd: "2018-03-22"
59
}
60
]}
61
];
62
63
// create a data tree
64
var treeData = anychart.data.tree(data, "as-tree");
65
66
// create a chart
67
chart = anychart.ganttProject();
68
69
// set the data
70
chart.data(treeData);
71
72
// access data grid buttons
73
var buttons = chart.dataGrid().buttons();
74
75
// configure data grid buttons
76
buttons.fontWeight(600);
77
buttons.fontSize(16);
78
buttons.fontFamily("Courier");
79
buttons.background().fill(null);
80
buttons.background().stroke(null);
81
buttons.width(30);
82
buttons.cursor("default");
83
84
// configure data grid buttons in the normal state
85
buttons.normal().content("[+]");
86
buttons.normal().fontColor("#ef6c00");
87
88
// configure data grid buttons in the hover state
89
buttons.hovered().content("[+]");
90
buttons.hovered().fontColor(anychart.color.lighten("#ef6c00"));
91
92
// configure data grid buttons in the selected state
93
buttons.selected().content("[-]");
94
buttons.selected().fontColor("#64b5f6");
95
96
// configure the scale
97
chart.getTimeline().scale().maximum("2018-03-27");
98
99
// set the container id
100
chart.container("container");
101
102
// initiate drawing the chart
103
chart.draw();
104
105
// fit elements to the width of the timeline
106
chart.fitAll();
107
});