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", 0.7, 6.1, 8.1, 12.6],
6
["February", 0.6, 6.3, 8.5, 12.2],
7
["March", 1.9, 8.5, 10.3, 13.1],
8
["April", 3.1, 10.8, 13.4, 15.9],
9
["May", 5.7, 14.4, 14.9, 16.4]
10
]);
11
12
// map the data
13
var seriesData_1 = data.mapAs({x: 0, low: 1, high: 2});
14
var seriesData_2 = data.mapAs({x: 0, low: 3, high: 4});
15
16
// create a chart
17
var chart = anychart.bar();
18
19
// create the first series, set the data and name
20
var series1 = chart.rangeBar(seriesData_1);
21
series1.name("2004");
22
23
// configure the visual settings of the first series
24
series1.normal().fill("#00cc99", 0.3);
25
series1.hovered().fill("#00cc99", 0.1);
26
series1.selected().fill("#00cc99", 0.5);
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.rangeBar(seriesData_2);
33
series2.name("2005");
34
35
// configure the visual settings of the second series
36
series2.normal().fill("#0066cc", 0.3);
37
series2.hovered().fill("#0066cc", 0.1);
38
series2.selected().fill("#0066cc", 0.5);
39
series2.normal().hatchFill("forward-diagonal", "#0066cc", 1, 15);
40
series2.hovered().hatchFill("forward-diagonal", "#0066cc", 1, 15);
41
series2.selected().hatchFill("forward-diagonal", "#0066cc", 1, 15);
42
series2.normal().stroke("#0066cc");
43
series2.hovered().stroke("#0066cc", 2);
44
series2.selected().stroke("#0066cc", 4);
45
46
// set the chart title
47
chart.title("Range Bar Chart: Appearance");
48
49
// set the titles of the axes
50
chart.xAxis().title("Month");
51
chart.yAxis().title("Temperature, \xb0C");
52
53
// set the container id
54
chart.container("container");
55
56
// initiate drawing the chart
57
chart.draw();
58
});