HTMLcopy
1
<button onclick="asc();">Ascending Order</button>
2
<button onclick="desc();">Descending Order</button>
3
<button onclick="none();">No Sorting</button>
4
<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;
2
3
function asc() {
4
5
// Set sorting.
6
chart.sort('asc');
7
}
8
9
function desc() {
10
11
// Set sorting.
12
chart.sort('desc');
13
}
14
15
function none() {
16
17
// Disable sorting.
18
chart.sort('none');
19
}
20
anychart.onDocumentReady(function () {
21
chart = anychart.pie([
22
{x: 'Cycling', value: 3},
23
{x: 'Swimming', value: 10},
24
{x: 'Run', value: 6},
25
{x: 'Hiking', value: 7},
26
{x: 'Alpinism', value: 20}
27
]);
28
chart.title('Set the sorting mode');
29
chart.container('container');
30
chart.draw();
31
});