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
5
var rangeData1 = [
6
{name: "Task 1", start: Date.UTC(2004,0,4), end: Date.UTC(2004,7,1),
7
normal: {fill: "#01b53f", stroke: "null"},
8
hovered: {fill: "#01b53f", stroke: "null"},
9
selected: {fill: "#01b53f", stroke: "null"}
10
},
11
{name: "Task 2", start: Date.UTC(2004,7,1), end: Date.UTC(2005,8,10),
12
normal: {fill: "#ff6600", stroke: "null"},
13
hovered: {fill: "#ff6600", stroke: "null"},
14
selected: {fill: "#ff6600", stroke: "null"}
15
}
16
];
17
18
var rangeData2 = [
19
{name: "New Task 1", start: Date.UTC(2005,10,1), end: Date.UTC(2006,5,1),
20
normal: {fill: "#00a8e0", stroke: "null"},
21
hovered: {fill: "#00a8e0", stroke: "null"},
22
selected: {fill: "#00a8e0", stroke: "null"}
23
},
24
{name: "New Task 2", start: Date.UTC(2006,5,15), end: Date.UTC(2006,11,1),
25
normal: {fill: "#f6bc16", stroke: "null"},
26
hovered: {fill: "#f6bc16", stroke: "null"},
27
selected: {fill: "#f6bc16", stroke: "null"}
28
}
29
];
30
31
var momentData1 = [
32
{x: Date.UTC(2004,2,21), y: "Meeting 1"},
33
{x: Date.UTC(2005,3,19), y: "Meeting 2"},
34
{x: Date.UTC(2006,1,1), y: "Meeting 3"}
35
];
36
37
var momentData2 = [
38
{x: Date.UTC(2004,5,12), y: "Training 1"},
39
{x: Date.UTC(2005,5,1), y: "Training 2"},
40
{x: Date.UTC(2006,1,26), y: "Training 3"}
41
];
42
43
// create a chart
44
var chart = anychart.timeline();
45
46
// prevent zooming the chart with the mouse wheel
47
chart.interactivity().zoomOnMouseWheel(false);
48
49
// create the first range series, set the data and name
50
var rangeSeries1 = chart.range(rangeData1);
51
rangeSeries1.name("Tasks");
52
53
// create the second range series, set the data and name
54
var rangeSeries2 = chart.range(rangeData2);
55
rangeSeries2.name("New Tasks");
56
57
// create the first moment series, set the data and name
58
var momentSeries1 = chart.moment(momentData1);
59
momentSeries1.name("Meetings");
60
61
// create the second moment series, set the data and name
62
var momentSeries2 = chart.moment(momentData2);
63
momentSeries2.name("Trainings");
64
65
// set the chart title
66
chart.title("Timeline Chart: Individual Ranges");
67
68
// set the container id
69
chart.container("container");
70
71
// initiate drawing the chart
72
chart.draw();
73
});