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
3
// create data
4
var currentDate = new Date();
5
var currentYear = currentDate.getFullYear();
6
var rangeData = [
7
["Task 1", Date.UTC(currentYear,0,1), Date.UTC(2019,4,1)],
8
["Task 2", Date.UTC(currentYear,4,1), Date.UTC(2019,11,31)]
9
];
10
11
// create a chart
12
var chart = anychart.timeline();
13
14
// prevent zooming the chart with the mouse wheel
15
chart.interactivity().zoomOnMouseWheel(false);
16
17
// create a range series, set the data and name
18
var rangeSeries = chart.range(rangeData);
19
rangeSeries.name("Tasks");
20
21
// create and configure a today marker
22
var todayMarker = chart.todayMarker();
23
todayMarker.stroke("#dd2c00", 3);
24
25
// create and configure a text marker
26
var textMarker = chart.textMarker(0);
27
var todayMarkerValue = todayMarker.value();
28
textMarker.value(todayMarkerValue);
29
textMarker.text(
30
anychart.format.dateTime(todayMarkerValue, "dd MMMM")
31
);
32
textMarker.fontColor("#dd2c00");
33
textMarker.fontWeight(600);
34
textMarker.offsetX(-10);
35
36
// set the chart title
37
chart.title("Timeline Chart: Today Marker (+ Text Marker)");
38
39
// set the container id
40
chart.container("container");
41
42
// initiate drawing the chart
43
chart.draw();
44
});