HTMLcopy
x
1
<button onclick="removeTick()">Remove a tick</button>
2
<button onclick="setTickArray()">Load a set of ticks</button>
3
4
<div id="container"></div>
CSScopy
15
1
html, body {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
button {
8
margin: 10px 0 0 10px;
9
}
10
#container {
11
position: absolute;
12
width: 100%;
13
top: 35px;
14
bottom: 0;
15
}
JavaScriptcopy
33
1
var chart, data;
2
anychart.onDocumentReady(function () {
3
data = [
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
chart = anychart.column(data);
11
12
// set the chart title
13
chart.title("Ticks Array: Get and Modify");
14
15
// set the container id
16
chart.container("container");
17
18
// initiate drawing the chart
19
chart.draw();
20
});
21
function removeTick(){
22
// get the array of generated ticks
23
ticksArray = chart.yScale().ticks().get();
24
// modify the array of ticks
25
if (ticksArray.length > 2) ticksArray.pop();
26
// set the array of ticks
27
chart.yScale().ticks().set(ticksArray);
28
}
29
function setTickArray(){
30
// set a fixed array as ticks
31
var ticksArray = [0, 1, 2, 2.8];
32
chart.yScale().ticks().set(ticksArray);
33
};