HTMLcopy
1
<button onclick="crosshairEnabled(false)">Disable</button>
2
<button onclick="crosshairEnabled(true)">Enable</button>
3
<div id="container"></div>
CSScopy
15
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
button {
8
margin: 10px 0 0 10px;
9
}
10
#container {
11
position: absolute;
12
width: 100%;
13
top: 35px;
14
bottom: 0;
15
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// create data
4
var data = [
5
["January", 12000, 10000],
6
["February", 15000, 12000],
7
["March", 16000, 18000],
8
["April", 15000, 11000],
9
["May", 14000, 9000]
10
];
11
12
// create a line chart
13
chart = anychart.line();
14
15
// set the data
16
chart.data(data);
17
18
// enable the crosshair
19
chart.crosshair(true);
20
21
// set the chart title
22
chart.listen("chartDraw", function () {
23
chart.title("Crosshair: Enabled = "
24
+ chart.crosshair().enabled());
25
});
26
27
// set the container id
28
chart.container("container");
29
30
// initiate drawing the chart
31
chart.draw();
32
});
33
34
// enable / disable the crosshair
35
function crosshairEnabled(enabled) {
36
chart.crosshair(enabled);
37
}