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
var stage = anychart.graphics.create("container");
3
4
var chart = anychart.line([6, 10, 18, 11, 9]);
5
chart.yScale().minimum(0);
6
chart.xScale("linear");
7
chart.bounds("9%", 0, "100%", "100%");
8
9
chart.annotations([{
10
type: "ellipse",
11
xAnchor: 1.9,
12
valueAnchor: 17,
13
secondXAnchor: 2.1,
14
secondValueAnchor: 19,
15
fill: "#4CAF50 0.5",
16
stroke: "3 #FF9800"
17
}]);
18
19
var controller = chart.annotations();
20
21
var annotation = chart.annotations().getAnnotationAt(0);
22
23
chart.title("Select/unselect methods.");
24
chart.container(stage);
25
chart.draw();
26
27
createLabel("Select annotation", 0, function () {
28
29
// Set selection mode.
30
controller.select(annotation);
31
});
32
33
createLabel("Unselect annotation", 30, function () {
34
35
// Disable selection mode.
36
controller.unselect(annotation);
37
});
38
39
40
function createLabel(text, offset, action) {
41
var label = anychart.standalones.label();
42
label.text(text);
43
label.parentBounds(0, offset, 100, 100);
44
label.listen("click", action);
45
label.background({fill: "#9E9E9E"});
46
label.fontColor("#fff");
47
label.padding(5);
48
label.container(stage);
49
label.draw();
50
}
51
});