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
var data = [
3
{id: 1, nameField: 'Phase 1 - Strategic Plan', progressValue: 0.14, actualStart: '2000-02-24', actualEnd: '2000-02-27'},
4
{id: 2, nameField: 'Self-Assessment', parent: 1, progressValue: 0.25, actualStart: '2000-02-24', actualEnd: '2000-02-29'},
5
{id: 3, nameField: 'Define business vision', parent: 2, progressValue: 0, actualStart: '2000-02-24T24:00', actualEnd: '2000-02-25T09:00', connectTo: 4, connectorType: 'finish-start'},
6
{id: 4, nameField: 'Identify available skills, information and support', parent: 2, progressValue: 0, actualStart: '2000-02-26T00:00', actualEnd: '2000-02-26T09:00', connectTo: 5, connectorType: 'finish-start'},
7
{id: 5, nameField: 'Decide whether to proceed', parent: 2, progressValue: 0, actualStart: '2000-02-27', actualEnd: '2000-02-28T08:00', connectTo: 6, connectorType: 'finish-start'},
8
{id: 6, nameField: 'Define the Opportunity', parent: 1, progressValue: 0.27, actualStart: '2000-02-28T08:00', actualEnd: '2000-02-29'},
9
{id: 7, nameField: 'Research the market and competition', parent: 6, progressValue: 0, actualStart: '2000-02-26T08:00', actualEnd: '2000-02-27'}
10
];
11
12
var treeData = anychart.data.tree(data, 'as-table');
13
14
var mapping = treeData.mapAs({name: 'nameField'});
15
16
var item = mapping.search('id', 2);
17
18
// Get child by index.
19
var getChildAt = item.getChildAt(1);
20
21
var parent = treeData.search('id', 7);
22
parent.addChild(getChildAt);
23
24
var chart = anychart.ganttProject();
25
chart.data(mapping);
26
chart.title('Get and use child by index');
27
chart.container('container');
28
chart.draw();
29
chart.fitAll();
30
});