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
// the data used in this sample can be obtained from the CDN
4
// https://cdn.anychart.com/csv-data/csco-daily.js
5
// create a data table using this data
6
var dataTable = anychart.data.table();
7
dataTable.addData(get_csco_daily_short_data());
8
9
// map the data
10
var mapping = dataTable.mapAs({value: 4});
11
12
// create a stock chart
13
var chart = anychart.stock();
14
15
// create a plot on the chart
16
var plot = chart.plot(0);
17
18
// create a line series
19
plot.line(mapping).name("CSCO");
20
21
var eventMarkers = plot.eventMarkers();
22
23
// add the first group of event markers
24
eventMarkers.group(0, [
25
{
26
"date": "2006-06-08",
27
"description": "Cisco announced the acquisition of Audium Corporation."
28
},
29
{
30
"date": "2008-04-27",
31
"description": "Cisco announced its intent to acquire PostPath, Inc."
32
}
33
]);
34
35
// set the symbol of the first group
36
eventMarkers.group(0).format("A");
37
38
// add the second group of event markers
39
eventMarkers.group(1, [
40
{
41
"date": "2009-02-10",
42
"description": "Cisco and Tata Consultancy Services announced strategic alliance."
43
},
44
{
45
"date": "2009-02-12",
46
"description": "Cisco unveiled 'Intelligent Urbanisation' vision for Bangalore."
47
}
48
]);
49
50
// set the symbol of the second group
51
eventMarkers.group(1).format("B");
52
53
// set the chart title
54
chart.title("Event Markers: Data\ngroup()");
55
56
// set the container id
57
chart.container("container");
58
59
// initiate drawing the chart
60
chart.draw();
61
});