HTMLcopy
1
<div id="container"></div>
CSScopy
12
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
#container {
8
position: absolute;
9
width: 100%;
10
top: 25px;
11
bottom: 0;
12
}
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 event markers
24
plot.eventMarkers({"groups": [
25
{
26
"data": [
27
{
28
"date": "2006-06-08",
29
"description": "Cisco announced the acquisition of Audium Corporation."
30
},
31
{
32
"date": "2008-04-27",
33
"description": "Cisco announced its intent to acquire PostPath, Inc."
34
}
35
]
36
}
37
]});
38
39
// configure the appearance of event markers
40
41
eventMarkers.normal().fill("#d1ead9");
42
eventMarkers.hovered().fill("white");
43
eventMarkers.selected().fill("white");
44
45
eventMarkers.normal().stroke("#009933", 2);
46
eventMarkers.hovered().stroke("#009933", 2);
47
eventMarkers.selected().stroke("#004d1a", 2);
48
49
eventMarkers.normal().fontColor("#009933");
50
eventMarkers.hovered().fontColor("#009933");
51
eventMarkers.selected().fontColor("#004d1a");
52
eventMarkers.normal().fontWeight(600);
53
54
// set the chart title
55
chart.title("Event Markers: Appearance");
56
57
// set the container id
58
chart.container("container");
59
60
// initiate drawing the chart
61
chart.draw();
62
});