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/event-markers/data.json
4
anychart.data.loadJsonFile(
5
'https://cdn.anychart.com/samples/gantt-general-features/event-markers/data.json',
6
function (data) {
7
// create data tree on raw data
8
var treeData = anychart.data.tree(data, 'as-table');
9
10
// create resource gantt chart
11
var chart = anychart.ganttResource();
12
13
// set data for the chart
14
chart.data(treeData);
15
16
// set the spliter position
17
chart.splitterPosition(200);
18
19
// getting chart's timeline
20
var timeline = chart.getTimeline();
21
22
// create range maker with text
23
timeline
24
.rangeMarker(0)
25
.from(Date.UTC(2014, 3, 6))
26
.to(Date.UTC(2014, 3, 10))
27
.fill('#ffd54f 0.2');
28
timeline
29
.textMarker(0)
30
.value(Date.UTC(2014, 3, 8))
31
.text(
32
'<span style="">Conference</span><br/><b>"Robotics Courses"</b>'
33
)
34
.align('center')
35
.hAlign('center')
36
.rotation(0)
37
.useHtml(true)
38
.fontSize(18)
39
.fontColor('#997400')
40
.fontOpacity(1)
41
.zIndex(50);
42
43
// create line maker with text
44
timeline
45
.lineMarker(0)
46
.value(Date.UTC(2014, 3, 22))
47
.stroke('2 #212121')
48
.zIndex(50);
49
timeline
50
.textMarker(1)
51
.value(Date.UTC(2014, 3, 22))
52
.text(
53
'<span style="">Robotics Exhibition</span><br/><b>"The Opening Night"</b>'
54
)
55
.align('center')
56
.hAlign('left')
57
.offsetX(110)
58
.rotation(0)
59
.useHtml(true)
60
.fontSize(18)
61
.fontColor('#212121')
62
.fontOpacity(1)
63
.zIndex(50);
64
65
// create line maker with text
66
timeline
67
.lineMarker(1)
68
.value(Date.UTC(2014, 3, 29))
69
.stroke('2 #ef6c00')
70
.zIndex(50);
71
timeline
72
.textMarker(2)
73
.value(Date.UTC(2014, 3, 29))
74
.text(
75
'<span style="">Robotics Competition</span><br/><b>"Choice of Path"</b>'
76
)
77
.align('center')
78
.offsetX(-105)
79
.offsetY(45)
80
.hAlign('right')
81
.rotation(0)
82
.useHtml(true)
83
.fontSize(18)
84
.fontColor('#994500')
85
.fontOpacity(1)
86
.zIndex(50);
87
88
// set container id for the chart
89
chart.container('container');
90
91
// initiate chart drawing
92
chart.draw();
93
94
// zoom chart all dates range
95
chart.fitAll();
96
}
97
);
98
});