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 treeData = anychart.data.tree(getData(), 'as-tree');
3
chart = anychart.ganttProject();
4
chart.data(treeData);
5
6
// --- Common configuration.
7
var timeline = chart.getTimeline();
8
chart.xScale().minimumGap(0.3);
9
chart.xScale().maximumGap(0.3);
10
chart.defaultRowHeight(50);
11
timeline.tasks().progress().height('50%').stroke('0.5 navy');
12
timeline.baselines().progress().fill('lightgreen').stroke('green');
13
14
// --- Configuring markers.
15
// This will configure all start markers.
16
timeline.elements().startMarker()
17
.enabled(true)
18
.type('star5')
19
.stroke('lightgrey');
20
21
// This will configure all end markers.
22
timeline.elements().endMarker()
23
.enabled(true)
24
.type('star5')
25
.stroke('lightgrey');
26
27
// This will configure startMarker for both tasks and groupingTasks.
28
timeline.tasks().startMarker()
29
.fill('red');
30
31
// This will configure endMarker for both tasks and groupingTasks.
32
timeline.tasks().endMarker()
33
.fill('green');
34
35
// Disabling progress start marker. This will disable startMarker for both tasks and groupingTasks.
36
timeline.tasks().progress().startMarker(false);
37
38
timeline.tasks().progress().endMarker()
39
.type('triangleUp')
40
.offsetY(10)
41
.fill('orange');
42
43
timeline.baselines().startMarker()
44
.fill('purple');
45
46
timeline.baselines().endMarker()
47
.fill('#009999');
48
49
// Disabling baseline progress start marker.
50
timeline.baselines().progress().startMarker(false);
51
52
timeline.baselines().progress().endMarker()
53
.type('triangleUp')
54
.offsetY(10)
55
.fill('pink');
56
57
chart.container('container');
58
chart.draw();
59
chart.fitAll();
60
});
61
62
63
function getData() {
64
return [
65
{
66
id: 1,
67
name: 'Grouping task',
68
baselineStart: Date.UTC(2020, 2, 4),
69
baselineEnd: Date.UTC(2020, 2, 25),
70
baselineProgressValue: 0.5,
71
children: [
72
{
73
id: 2,
74
name: 'Child task 1',
75
actualStart: Date.UTC(2020, 2, 1),
76
actualEnd: Date.UTC(2020, 2, 10),
77
progressValue: 0.4,
78
baselineStart: Date.UTC(2020, 2, 4),
79
baselineEnd: Date.UTC(2020, 2, 12),
80
baselineProgressValue: 0.6
81
},
82
{
83
id: 3,
84
name: 'Child task 2',
85
actualStart: Date.UTC(2020, 2, 15),
86
actualEnd: Date.UTC(2020, 2, 24),
87
progressValue: 0.2,
88
baselineStart: Date.UTC(2020, 2, 12),
89
baselineEnd: Date.UTC(2020, 2, 25),
90
baselineProgressValue: 0.7
91
}
92
]
93
}
94
];
95
}