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.stick();
18
19
// set the interactivity mode
20
chart.interactivity("by-x");
21
22
// create the first series, set the data and name
23
var series1 = chart.stick(seriesData_1);
24
series1.name("2004");
25
26
// configure the visual settings of the first series
27
series1.normal().stroke("#00cc99", 1, "10 5", "round");
28
series1.hovered().stroke("#00cc99", 2, "10 5", "round");
29
series1.selected().stroke("#00cc99", 4, "10 5", "round");
30
31
// create the second series, set the data and name
32
var series2 = chart.stick(seriesData_2);
33
series2.name("2005");
34
35
// configure the visual settings of the second series
36
series2.normal().stroke("#0066cc");
37
series2.hovered().stroke("#0066cc", 2);
38
series2.selected().stroke("#0066cc", 4);
39
40
// set the chart title
41
chart.title("Stick Chart: Appearance");
42
43
// set the titles of the axes
44
var xAxis = chart.xAxis();
45
xAxis.title("Month");
46
var yAxis = chart.yAxis();
47
yAxis.title("Sales, $");
48
49
// set the container id
50
chart.container("container");
51
52
// initiate drawing the chart
53
chart.draw();
54
});