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 = getData();
3
var chart = anychart.ganttProject();
4
chart.defaultRowHeight(40);
5
chart.data(data, 'as-tree');
6
var timeline = chart.getTimeline();
7
chart.xScale().minimumGap(0.2).maximumGap(0.2);
8
9
//Getting the previews.
10
var previews = timeline.milestones().preview();
11
previews.enabled(true);
12
13
//Styling previews.
14
timeline.milestones().preview({
15
fill: 'lightgreen',
16
stroke: 'purple'
17
});
18
19
chart.title('Milestones previews displayed on grouping tasks.');
20
chart.container('container');
21
chart.draw();
22
chart.fitAll();
23
});
24
25
function getData() {
26
return [
27
{
28
id: 1,
29
name: 'Collapsed grouping task',
30
collapsed: true,
31
children: [
32
{
33
id: 2,
34
name: 'Milestone 1',
35
shortName: 'M1',
36
actualStart: Date.UTC(2019, 3, 1)
37
},
38
{
39
id: 3,
40
name: 'Milestone 2',
41
shortName: 'M2',
42
actualStart: Date.UTC(2019, 3, 10)
43
},
44
{
45
id: 3,
46
name: 'Milestone 3',
47
shortName: 'M3',
48
actualStart: Date.UTC(2019, 3, 14)
49
},
50
{
51
id: 4,
52
name: 'Milestone 4',
53
shortName: 'M4',
54
actualStart: Date.UTC(2019, 3, 20)
55
}
56
]
57
},
58
{
59
id: 5,
60
name: 'Expanded grouping task',
61
children: [
62
{
63
id: 6,
64
name: 'Milestone 5',
65
shortName: 'M5',
66
actualStart: Date.UTC(2019, 3, 17)
67
},
68
{
69
id: 7,
70
name: 'Milestone 6',
71
shortName: 'M6',
72
actualStart: Date.UTC(2019, 4, 1)
73
},
74
{
75
id: 8,
76
name: 'Milestone 7',
77
shortName: 'M7',
78
actualStart: Date.UTC(2019, 4, 12)
79
}
80
]
81
}
82
];
83
}