HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
var chart = anychart.scatter();
3
4
chart.marker(getRandomArbitrary(10, 50, 100));
5
chart.marker(getRandomArbitrary(150, 200, 100));
6
7
// create annotation
8
var annotation = chart.annotations();
9
annotation.zIndex(10);
10
// create annotation trendChannel
11
annotation.trendChannel({
12
// X - part of the first anchor
13
xAnchor: '4',
14
// Y - part of the first anchor
15
valueAnchor: 0,
16
// X - part of the second anchor
17
secondXAnchor: '110',
18
// Y - part of the second anchor
19
secondValueAnchor: 105,
20
// X - part of the third anchor
21
thirdXAnchor: '80',
22
// Y - part of the third anchor
23
thirdValueAnchor: 135,
24
// set stroke settings
25
stroke: '2 #6E9C4E',
26
// set fill settings
27
fill: '#6E9C4E 0.3',
28
// set hover fill/stroke settings
29
hovered: {
30
fill: '#6E9C4E 0.3',
31
stroke: '2 #6E9C4E'
32
}
33
});
34
// create annotation trendChannel
35
annotation.trendChannel({
36
// X - part of the first anchor
37
xAnchor: '4',
38
// Y - part of the first anchor
39
valueAnchor: 145,
40
// X - part of the second anchor
41
secondXAnchor: '100',
42
// Y - part of the second anchor
43
secondValueAnchor: 235,
44
// X - part of the third anchor
45
thirdXAnchor: '100',
46
// Y - part of the third anchor
47
thirdValueAnchor: 300,
48
// set stroke settings
49
stroke: '2 #e06666',
50
// set fill settings
51
fill: '#e06666 0.3',
52
// set hover fill/stroke settings
53
hovered: {
54
fill: '#e06666 0.3',
55
stroke: '2 #e06666'
56
}
57
});
58
59
// set container id for the chart
60
chart.container('container');
61
// initiate chart drawing
62
chart.draw();
63
});
64
65
function getRandomArbitrary(min, max, count) {
66
var result = [];
67
for (var i = 5; i < count; i++) {
68
min++;
69
max++;
70
result.push([i, Math.ceil(Math.random() * (max - min) + min)]);
71
}
72
return result;
73
}