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
// create data set on our data
3
var dataSet = anychart.data.set([
4
["P1" , 3.6 , 2.3],
5
["P2" , 7.1 , 4.0],
6
["P3" , 8.5 , 6.2],
7
["P4" , 9.2 , 11.8],
8
["P5" , 10.1, 13.0],
9
["P6" , 11.6, 13.9],
10
["P7" , 16.4, 18.0],
11
["P8" , 18.0, 23.3],
12
["P9" , 13.2, 24.7],
13
["P10", 12.0, 18.0],
14
["P11", 3.2 , 15.1],
15
["P12", 4.1 , 11.3],
16
["P13", 6.3 , 14.2],
17
["P14", 9.4 , 13.7],
18
["P15", 11.5, 9.9],
19
["P16", 13.5, 12.1],
20
["P17", 14.8, 13.5],
21
["P18", 16.6, 15.1],
22
["P19", 18.1, 17.9],
23
["P20", 17.0, 18.9]
24
]);
25
26
// create line chart
27
var chart = anychart.column();
28
29
var crosshair = chart.crosshair();
30
// the same as above
31
crosshair.enabled(true);
32
// disable the x-axis labels
33
crosshair.yLabel(false);
34
35
// adding and adjusting extra Y scale
36
var extraYScale = anychart.scales.linear();
37
extraYScale.minimum(0);
38
extraYScale.maximum(100);
39
var extraTicks = extraYScale.ticks();
40
extraTicks.interval(10);
41
42
// adding and adjusting extra X axis
43
var extraYAxis = chart.yAxis(1);
44
extraYAxis.orientation("right");
45
extraYAxis.scale(extraYScale);
46
var extraLabels = extraYAxis.labels();
47
extraLabels.format(function(){
48
return (this.value+"%");
49
});
50
51
// turn on chart animation
52
chart.animation(true);
53
54
// set chart title text settings
55
chart.title("Column Chart with a Crosshair");
56
57
// create first series with mapped data
58
chart.column(dataSet.mapAs({x: [0], value: [1]}));
59
chart.column(dataSet.mapAs({x: [0], value: [2]}));
60
61
// set container id for the chart
62
chart.container("container");
63
// initiate chart drawing
64
chart.draw();
65
});