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: 1515974400000,
9
actualEnd: 1520640000000,
10
budget: 80000,
11
children: [
12
{
13
id: "1_1",
14
name: "Analysis",
15
actualStart: 1515974400000,
16
actualEnd: 1516838400000,
17
budget: 10000
18
},
19
{
20
id: "1_2",
21
name: "Design",
22
actualStart: 1516406400000,
23
actualEnd: 1517702400000,
24
budget: 20000
25
},
26
{
27
id: "1_3",
28
name: "Meeting",
29
actualStart: 1517788800000,
30
actualEnd: 1517788800000,
31
budget: 0
32
},
33
{
34
id: "1_4",
35
name: "Implementation",
36
actualStart: 1517788800000,
37
actualEnd: 1519430400000,
38
budget: 30000
39
},
40
{
41
id: "1_5",
42
name: "Testing",
43
actualStart: 1519516800000,
44
actualEnd: 1520640000000,
45
budget: 20000
46
}
47
]}
48
];
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
// configure the first data grid column
60
column_1 = chart.dataGrid().column(0);
61
column_1.setColumnFormat("budget", "direct-numbering");
62
column_1.title("direct-numbering");
63
column_1.title().fontSize(10);
64
column_1.title().wordWrap("break-word");
65
column_1.title().padding(7);
66
67
// configure the second data grid column
68
column_2 = chart.dataGrid().column(1);
69
column_2.setColumnFormat("budget", "financial");
70
column_2.title().useHtml(true);
71
column_2.title("financial");
72
column_2.title().fontSize(10);
73
column_2.depthPaddingMultiplier(0);
74
column_2.collapseExpandButtons(false);
75
76
// configure the scale
77
chart.getTimeline().scale().maximum("2018-03-15");
78
79
// set the container id
80
chart.container("container");
81
82
// initiate drawing the chart
83
chart.draw();
84
85
// fit elements to the width of the timeline
86
chart.fitAll();
87
});