HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// The data used in this sample can be obtained from the CDN
3
// https://cdn.anychart.com/samples/gantt-general-features/styling-timeline/data.json
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/gantt-general-features/styling-timeline/data.json',
6
function (data) {
7
// create data tree on raw data
8
var treeData = anychart.data.tree(data, 'as-table');
9
10
// create project gantt chart
11
var chart = anychart.ganttProject();
12
13
// set data for the chart
14
chart.data(treeData);
15
16
// set the splitter position
17
chart.splitterPosition(200);
18
19
// setting common rows separation stroke
20
chart.rowStroke('#414554 0.6');
21
22
// styling the timeline
23
chart
24
.getTimeline()
25
.rowEvenFill('#e4e5ea 0.5')
26
.rowOddFill('#fff')
27
.rowHoverFill('#f4e8ec')
28
.rowSelectedFill('#d1b8bf')
29
.columnStroke('#414554')
30
.baselines()
31
.above(true);
32
// making baseline bar display above an actual time's bar
33
// styling timeline's elements
34
chart.getTimeline().elements().fill('#6aabcc').stroke('#45738b');
35
chart.getTimeline().baselines().fill('#cf9ead').stroke('#6f5264');
36
chart
37
.getTimeline()
38
.milestones()
39
.fill('#96246a 0.7')
40
.stroke('2 #96246a 1');
41
chart
42
.getTimeline()
43
.groupingTasks()
44
.fill('#938d9c 0.7')
45
.stroke('#938d9c');
46
chart
47
.getTimeline()
48
.groupingTasks()
49
.progress()
50
.fill('#61687d 0.8')
51
.stroke('#61687d 1');
52
chart.getTimeline().connectors().fill('#333').stroke({
53
color: '#333',
54
dash: '3 2'
55
});
56
chart
57
.getTimeline()
58
.elements()
59
.selected()
60
.fill('#01579b')
61
.stroke('#fff');
62
63
// set container id for the chart
64
chart.container('container');
65
66
// initiate chart drawing
67
chart.draw();
68
69
// zoom chart all dates range
70
chart.fitAll();
71
}
72
);
73
});