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
// create a data set
4
var data = anychart.data.set([
5
["January", 12000, 10000],
6
["February", 15000, 12000],
7
["March", 16000, 18000],
8
["April", 15000, 11000],
9
["May", 14000, 9000]
10
]);
11
12
// map the data
13
var seriesData_1 = data.mapAs({x: 0, value: 1});
14
var seriesData_2 = data.mapAs({x: 0, value: 2});
15
16
// create a chart
17
var chart = anychart.area();
18
19
// set the interactivity mode
20
chart.interactivity().hoverMode("single");
21
22
// create the first series, set the data and name
23
var series1 = chart.area(seriesData_1);
24
series1.name("2004");
25
26
// configure the visual settings of the first series
27
series1.normal().fill("#00cc99", 0.3);
28
series1.hovered().fill("#00cc99", 0.1);
29
series1.selected().fill("#00cc99", 0.5);
30
series1.normal().stroke("#00cc99", 1, "10 5", "round");
31
series1.hovered().stroke("#00cc99", 2, "10 5", "round");
32
series1.selected().stroke("#00cc99", 4, "10 5", "round");
33
34
// create the second series, set the data and name
35
var series2 = chart.area(seriesData_2);
36
series2.name("2005");
37
38
// configure the visual settings of the second series
39
series2.normal().fill("#0066cc", 0.3);
40
series2.hovered().fill("#0066cc", 0.1);
41
series2.selected().fill("#0066cc", 0.5);
42
series2.normal().hatchFill("forward-diagonal", "#0066cc", 1, 15);
43
series2.hovered().hatchFill("forward-diagonal", "#0066cc", 1, 15);
44
series2.selected().hatchFill("forward-diagonal", "#0066cc", 1, 15);
45
series2.normal().stroke("#0066cc");
46
series2.hovered().stroke("#0066cc", 2);
47
series2.selected().stroke("#0066cc", 4);
48
49
// set the chart title
50
chart.title("Area Chart: Appearance");
51
52
// set the titles of the axes
53
chart.xAxis().title("Month");
54
chart.yAxis().title("Sales, $");
55
56
// set the container id
57
chart.container("container");
58
59
// initiate drawing the chart
60
chart.draw();
61
});