HTMLcopy
1
<button onclick="left()">Left</button>
2
<button onclick="counterclockwise()">Counterclockwise</button>
3
<button id="zoomButton" onclick="zoom()">+</button>
4
<button onclick="clockwise()">Clockwise</button>
5
<button onclick="right()">Right</button>
6
<div id="container"></div>
CSScopy
9
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
7
button {
8
margin: 10px 0 0 10px;
9
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
3
// set stage
4
stage = anychart.graphics.create("container");
5
6
layer = stage.layer();
7
// set data
8
var data_1 = [
9
{x: "Ice-Cream", value: 5000, fill:"#00FFFF"},
10
{x: "Sweets", value: 10000, fill:"#0DD9E6"},
11
{x: "Chocolates", value: 19000, fill:"#1AB2CC"},
12
{x: "Hot chocolate", value: 16000, fill:"#268CB2"},
13
{x: "Cookies", value: 9000, fill:"#336699"}
14
];
15
16
// chart type
17
var chart_1 = anychart.column();
18
chart_1.width(550);
19
chart_1.height(420);
20
chart_1.title("Sales");
21
chart_1.padding(40, 0, 0, 75);
22
var series_1 = chart_1.column(data_1);
23
series_1.stroke(null);
24
25
// draw
26
chart_1.container(layer);
27
chart_1.draw();
28
});
29
30
var ifScaled = false;
31
32
// zoom in and out
33
function zoom() {
34
var zoomButton = document.getElementById("zoomButton");
35
if (ifScaled) {
36
ifScaled = false;
37
layer.scale(0.8333, 0.8333, 0.9, 0.9);
38
zoomButton.innerHTML = "+";
39
} else {
40
zoomButton.innerHTML = "-";
41
layer.scale(1.2, 1.2, 0.9, 0.9);
42
ifScaled = true;
43
}
44
stage.suspend();
45
stage.resume();
46
};
47
48
// move left
49
function left() {
50
stage.suspend();
51
layer.translate(-5, 0);
52
stage.resume();
53
};
54
55
// move right
56
function right() {
57
stage.suspend();
58
layer.translate(5, 0);
59
stage.resume();
60
};
61
62
// turn clockwise
63
function clockwise() {
64
stage.suspend();
65
layer.rotate(90, 325, 250);
66
stage.resume();
67
};
68
69
// turn counterclockwise
70
function counterclockwise() {
71
stage.suspend();
72
layer.rotate(-90, 325, 250);
73
stage.resume();
74
};