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 tree on our data
4
var treeData = anychart.data.tree(getData(), anychart.enums.TreeFillingMethod.AS_TABLE);
5
6
// create project gantt chart
7
var chart = anychart.ganttProject();
8
9
// set data for the chart
10
chart.data(treeData);
11
12
// enable Gantt editing
13
chart.editing(true);
14
15
// edit connetors appearance
16
timeline = chart.getTimeline();
17
// set the connector control marker type
18
timeline.editStartConnectorMarkerType("arrowLeft");
19
timeline.editFinishConnectorMarkerType("arrowRight");
20
// connectors controls marker type
21
timeline.editStartConnectorMarkerSize(30);
22
timeline.editFinishConnectorMarkerSize(30);
23
// offsets of the connectors controls
24
timeline.editStartConnectorMarkerHorizontalOffset(10);
25
timeline.editFinishConnectorMarkerHorizontalOffset(-10);
26
timeline.editStartConnectorMarkerVerticalOffset(-7);
27
timeline.editFinishConnectorMarkerVerticalOffset(7);
28
29
// the width of the interval length editor
30
timeline.editIntervalWidth(15);
31
32
// disable tooltips
33
timeline.tooltip().enabled(false);
34
35
// set width for the datagrid
36
dataGrid = chart.dataGrid();
37
dataGrid.column(0).width(30);
38
dataGrid.column(1).width(270);
39
40
// set pixel position of the main splitter
41
chart.splitterPosition(300);
42
43
// rowheight
44
chart.defaultRowHeight(30);
45
46
// set container id for the chart
47
chart.container("container");
48
49
// initiate chart drawing
50
chart.draw();
51
52
// zoom chart to specified date
53
chart.fitAll();
54
55
chart.editing(true);
56
57
});
58
function getData() {
59
return [
60
{"id": "1", "name": "Phase 1 - Strategic Plan", "progressValue": "14%", "actualStart": 951350400000, "actualEnd": 954201600000},
61
{"id": "2", "name": "Self-Assessment", parent:"1", "progressValue": "25%", "actualStart": 951350400000, "actualEnd": 951955200000},
62
{"id": "3", "name": "Define business vision", parent:"2", "progressValue": "0%", "actualStart": 951408000000, "actualEnd": 951440400000, "connectTo": "4", "connectorType": "FinishStart"},
63
{"id": "4", "name": "Identify available skills and information", parent:"2", "progressValue": "0%", "actualStart": 951494400000, "actualEnd": 951526800000, "connectTo": "5", "connectorType": "FinishStart"},
64
{"id": "5", "name": "Decide whether to proceed", parent:"2", "progressValue": "0%", "actualStart": 951753600000, "actualEnd": 951786000000, "connectTo": "7", "connectorType": "FinishStart"},
65
{"id": "6", "name": "Define the Opportunity", parent:"1", "progressValue": "27%", "actualStart": 951782400000, "actualEnd": 952992000000},
66
{"id": "7", "name": "Research the market and competition", parent:"6", "progressValue": "0%", "actualStart": 951840000000, "actualEnd": 951872400000, "connectTo": "8", "connectorType": "FinishStart"},
67
{"id": "8", "name": "Interview owners of similar businesses", parent:"6", "progressValue": "60%", "actualStart": 951868800000, "actualEnd": 952473600000, "connectTo": "9", "connectorType": "FinishStart"},
68
{"id": "9", "name": "Identify needed resources", parent:"6", "progressValue": "0%", "actualStart": 952531200000, "actualEnd": 952650000000, "connectTo": "10", "connectorType": "FinishStart"},
69
{"id": "10", "name": "Identify operating cost elements", parent:"6", "progressValue": "0%", "actualStart": 952704000000, "actualEnd": 952995600000, "connectTo": "12", "connectorType": "FinishStart"}
70
];
71
}