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
// create timeline chart
3
var chart = anychart.timeline();
4
5
// create range series
6
var rangeSeries = chart.range(rangeData());
7
8
// set range series labels settings
9
rangeSeries
10
.labels()
11
.useHtml(true)
12
.fontColor('#fff')
13
.format(
14
'{%name}<br><span style="font-size: 85%">{%start}{dateTimeFormat:MM/dd} - {%end}{dateTimeFormat:MM/dd}</span>'
15
);
16
17
// set range series bar height
18
rangeSeries.height(50);
19
20
// create moment series
21
chart.moment(eventsData());
22
23
// create line marker and set it's value and stroke settings
24
chart.lineMarker().value('2019/03/29').stroke('2 #ff0000');
25
26
// set container id for the chart
27
chart.container('container');
28
// initiate chart drawing
29
chart.draw();
30
});
31
32
// range series data
33
function rangeData() {
34
return [
35
{
36
name: 'Planning',
37
start: '2019/01/22',
38
end: '2019/02/04',
39
fill: '#01b53f',
40
stroke: '#01b53f'
41
},
42
{
43
name: 'Research',
44
start: '2019/02/04',
45
end: '2019/02/18',
46
fill: '#1c4598',
47
stroke: '#1c4598'
48
},
49
{
50
name: 'Development',
51
start: '2019/02/18',
52
end: '2019/03/22',
53
fill: '#ff6600',
54
stroke: '#ff6600'
55
},
56
{
57
name: 'Implementation',
58
start: '2019/03/22',
59
end: '2019/04/05',
60
fill: '#00a8e0',
61
stroke: '#00a8e0'
62
},
63
{
64
name: 'Surveillance',
65
start: '2019/04/05',
66
end: '2019/04/19',
67
fill: '#f6bc16',
68
stroke: '#f6bc16'
69
},
70
{
71
name: 'Follow-Up',
72
start: '2019/04/19',
73
end: '2019/05/01',
74
fill: '#e51a23',
75
stroke: '#e51a23'
76
}
77
];
78
}
79
80
// event series data
81
function eventsData() {
82
return [
83
['2019/01/25', 'Initial approval'],
84
['2019/02/15', 'Final approval'],
85
['2019/03/09', 'Test 1'],
86
['2019/03/14', 'Test 2'],
87
['2019/03/19', 'Test 3'],
88
['2019/04/08', 'Check A/B Test'],
89
['2019/04/26', 'Customer Survey']
90
];
91
}