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
// data
4
var data = [
5
[2005, 10000],
6
[2006, 12000],
7
[2007, 18000],
8
[2008, 19000],
9
[2009, 29000]
10
];
11
12
// create chart
13
var chart = anychart.line(data);
14
chart.tooltip().format("Year: {%x}\nSales: {%value}");
15
16
// set y scale ticks interval
17
chart.yScale().minimum(0);
18
chart.yScale().maximum(30000);
19
chart.yScale().ticks().interval(5000);
20
21
// adjust y axis labels
22
chart.yAxis().labels().format("${%value}");
23
24
// set range marker
25
var range = chart.rangeMarker();
26
range.scale(chart.yScale());
27
range.from(0);
28
range.to(30000);
29
range.fill({
30
keys: [".1 #009900", ".5 #ffa000", ".9 #dd2c00"],
31
angle: -90,
32
opacity: 0.5
33
});
34
35
// set left text marker
36
var textMarker = chart.textMarker();
37
textMarker.axis(chart.yAxis());
38
textMarker.align("center");
39
textMarker.anchor("center");
40
textMarker.offsetX(10);
41
textMarker.value(25000);
42
textMarker.fontColor("#212121");
43
textMarker.text("Good");
44
textMarker.fontSize(13);
45
46
// set text marker at the center
47
var textMarker1 = chart.textMarker(2);
48
textMarker1.axis(chart.yAxis());
49
textMarker1.align("center");
50
textMarker1.anchor("center");
51
textMarker1.offsetX(10);
52
textMarker1.value(5000);
53
textMarker1.fontColor("#212121");
54
textMarker1.text("Severe");
55
textMarker1.fontSize(13);
56
57
// set text marker at the center
58
var textMarker2 = chart.textMarker(1);
59
textMarker2.axis(chart.yAxis());
60
textMarker2.align("center");
61
textMarker2.anchor("center");
62
textMarker2.offsetX(10);
63
textMarker2.value(15000);
64
textMarker2.fontColor("#212121");
65
textMarker2.text("Average");
66
textMarker2.fontSize(13);
67
68
// draw
69
chart.container("container");
70
chart.draw();
71
});