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
3
// set stage
4
var stage = anychart.graphics.create("container");
5
6
var layer = stage.layer();
7
// set data
8
var data_1 = anychart.data.set([
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
//buttons
30
var container = document.getElementById("container");
31
var b1 = document.createElement("button");
32
container.appendChild(b1);
33
b1.innerHTML = "+";
34
b1.style.padding = 0;
35
36
b1.style.position = "absolute";
37
b1.style.left = "320px";
38
b1.style.top = "455px";
39
b1.style.width = "30px";
40
b1.style.height = "30px";
41
42
var ifScaled = false;
43
44
b1.onclick = function() {
45
if (ifScaled) {
46
ifScaled = false;
47
layer.scale(0.8333, 0.8333, 0.9, 0.9);
48
b1.innerHTML = "+";
49
} else {
50
b1.innerHTML = "-";
51
layer.scale(1.2, 1.2, 0.9, 0.9);
52
ifScaled = true;
53
}
54
stage.suspend();
55
stage.resume();
56
};
57
58
59
// turn right
60
var b2 = document.createElement("button");
61
container.appendChild(b2);
62
63
b2.innerHTML = "Clockwise";
64
b2.style.padding = 0;
65
66
b2.style.position = "absolute";
67
b2.style.left = "355px";
68
b2.style.top = "455px";
69
b2.style.width = "100px";
70
b2.style.height = "30px";
71
b2.onclick = function() {
72
stage.suspend();
73
layer.rotate(90, 325, 250);
74
stage.resume();
75
};
76
77
78
// turn left
79
var b3 = document.createElement("button");
80
container.appendChild(b3);
81
b3.innerHTML = "Counterclockwise";
82
83
b3.style.padding = 0;
84
85
b3.style.position = "absolute";
86
b3.style.left = "195px";
87
b3.style.top = "455px";
88
b3.style.width = "120px";
89
b3.style.height = "30px";
90
b3.onclick = function() {
91
stage.suspend();
92
layer.rotate(-90, 325, 250);
93
stage.resume();
94
};
95
96
// move to the right
97
var b4 = document.createElement("button");
98
b4.innerHTML = "Right";
99
100
container.appendChild(b4);
101
b4.style.position = "absolute";
102
b4.style.left = "460px";
103
b4.style.top = "455px";
104
b4.style.width = "60px";
105
b4.style.height = "30px";
106
b4.style.padding = 0;
107
108
b4.onclick = function() {
109
stage.suspend();
110
layer.translate(5, 0);
111
stage.resume();
112
};
113
114
115
// move to the left
116
var b5 = document.createElement("button");
117
b5.innerHTML = "Left";
118
119
container.appendChild(b5);
120
121
b5.style.position = "absolute";
122
b5.style.left = "130px";
123
b5.style.top = "455px";
124
b5.style.width = "60px";
125
b5.style.height = "30px";
126
b5.style.padding = 0;
127
128
b5.onclick = function() {
129
stage.suspend();
130
layer.translate(-5, 0);
131
stage.resume();
132
};
133
});