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
// create area chart
3
var chart = anychart.area();
4
5
// turn on chart animation
6
chart.animation(true);
7
8
// set chart title text settings
9
chart
10
.title()
11
.enabled(true)
12
.useHtml(true)
13
.text(
14
'WebSite Metrics 2014<br/>' +
15
'<span style="color:#212121; font-size: 13px;">(unique visitors)</span>'
16
);
17
18
// axis title
19
chart.yAxis().title('Number of Visitors');
20
21
// create a logarithmic scale
22
var logScale = anychart.scales.log();
23
logScale
24
.minimum(1) // set scale minimum value
25
.maximumGap(0.2); // increase scale maximum gap
26
logScale.ticks().count(6); // set fixed major ticks count
27
logScale.minorTicks().mode('logarithmic'); // set minor ticks to use logarithmic mode
28
29
// set scale for the chart
30
// it force to use passed scale in all scale dependent entries such axes, grids, crosshairs etc
31
chart.yScale(logScale);
32
33
// create area series on passed data
34
var series = chart.area([
35
['Jan', 112],
36
['Feb', 163],
37
['Mar', 229],
38
['Apr', 990],
39
['May', 4104],
40
['Jun', 3250],
41
['Jul', 5720],
42
['Aug', 43],
43
['Sep', 61],
44
['Oct', 34],
45
['Nov', 45],
46
['Dec', 122]
47
]);
48
49
// set series data labels settings
50
series
51
.labels()
52
.enabled(true)
53
.fontColor('#212121')
54
.position('center-top')
55
.anchor('center-bottom');
56
57
// turn on series markers
58
series.markers(true);
59
60
// set series name
61
series.name('Number of Visitors');
62
63
// set up tooltips and interactivity settings
64
series
65
.tooltip()
66
.position('center-top')
67
.positionMode('point')
68
.anchor('left-top')
69
.offsetX(5)
70
.offsetY(5);
71
72
chart.interactivity().hoverMode('by-x');
73
74
// set container for the chart
75
chart.container('container');
76
// initiate chart drawing
77
chart.draw();
78
});