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
var chart, data;
2
anychart.onDocumentReady(function () {
3
dataSet = anychart.data.set([
4
{x: "Soprano", value: 1.1},
5
{x: "Alto", value: 0.1},
6
{x: "Tenor", value: 2.5},
7
{x: "Bass", value: 1.8}
8
]);
9
10
sortedData = dataSet.mapAs().sort('value', 'asc');
11
12
chart = anychart.column(sortedData);
13
14
chart.yGrid(true);
15
16
// set the chart title
17
chart.title("Ticks Array: Match the Data");
18
19
// set the container and draw a chart
20
chart.container("container").draw();
21
22
// create an empty array
23
var ticksArray = [];
24
25
// get data point value from the data set
26
// and populate the array
27
for (i=0;i<sortedData.getRowsCount();i++){
28
ticksArray[i] = sortedData.get(i, 'value');
29
}
30
// set the populated array as ticks array
31
chart.yScale().ticks().set(ticksArray);
32
33
});