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
// disable the default settings of data grid buttons
76
buttons.normal().content(null);
77
buttons.hovered().content(null);
78
buttons.selected().content(null);
79
buttons.background().stroke(null);
80
81
// set the background fill of data grid buttons in the normal state
82
buttons.normal().background().fill({
83
src: "https://cdn.anychart.com/samples/gantt-general-features/data-grid-buttons/close.png",
84
mode: "stretch"
85
});
86
87
// set the background fill of data grid buttons in the selected state
88
buttons.selected().background().fill({
89
src: "https://cdn.anychart.com/samples/gantt-general-features/data-grid-buttons/open.png",
90
mode: "stretch"
91
});
92
93
// configure the scale
94
chart.getTimeline().scale().maximum("2018-03-27");
95
96
// set the container id
97
chart.container("container");
98
99
// initiate drawing the chart
100
chart.draw();
101
102
// fit elements to the width of the timeline
103
chart.fitAll();
104
});