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
var data = getData();
3
4
var chart = anychart.resource();
5
chart.data(data).zoomLevel(1);
6
chart.title('Click on the chart. You have 3 clicks');
7
chart.listen('click', customListener);
8
9
var counter = 3;
10
11
function customListener(e) {
12
counter--;
13
chart.title('Click on the chart. You have ' + counter + ' clicks');
14
if (counter === 0) {
15
// Removes event listener
16
chart.unlisten('click', customListener);
17
chart.title('You have no more clicks');
18
}
19
}
20
21
chart.container('container');
22
chart.draw();
23
});
24
25
function getData() {
26
return [
27
{
28
name: 'Vasil Kiryienka',
29
description: 'Rider',
30
activities: [
31
{
32
name: 'World Championships',
33
start: '2016-10-12',
34
end: '2016-10-12'
35
}
36
]
37
},
38
{
39
name: 'Elia Viviani',
40
description: 'Rider',
41
activities: [
42
{
43
name: 'Paris - Tours',
44
start: '2016-10-09',
45
end: '2016-10-09',
46
fill: ['#1A237E', '#FFFFFF', '#D50000']
47
},
48
{
49
name: 'World Championships',
50
start: '2016-10-16',
51
end: '2016-10-16'
52
},
53
{
54
name: 'Abu Dhabi Tour',
55
start: '2016-10-20',
56
end: '2016-10-23',
57
fill: '#FFA000'
58
}
59
]
60
},
61
{
62
name: 'Ben Swift',
63
description: 'Rider',
64
activities: [
65
{
66
name: 'World Championships',
67
start: '2016-10-09',
68
end: '2016-10-09'
69
},
70
{
71
name: 'World Championships',
72
start: '2016-10-16',
73
end: '2016-10-16'
74
}
75
]
76
},
77
{
78
name: 'Michal Kwiatkowski',
79
description: 'Rider',
80
activities: [
81
{
82
name: 'World Championships',
83
start: '2016-10-09',
84
end: '2016-10-09'
85
},
86
{
87
name: 'Abu Dhabi Tour',
88
start: '2016-10-20',
89
end: '2016-10-23',
90
fill: '#FFA000'
91
}
92
]
93
},
94
{
95
name: 'Alex Peters',
96
description: 'Rider',
97
activities: [
98
{
99
name: 'Japan Cup',
100
start: '2016-10-23',
101
end: '2016-10-23',
102
fill: '#EF9A9A'
103
}
104
]
105
},
106
{
107
name: 'Ian Stannard',
108
description: 'Rider',
109
activities: [
110
{
111
name: 'Paris - Tours',
112
start: '2016-10-09',
113
end: '2016-10-09',
114
fill: ['#1A237E', '#FFFFFF', '#D50000']
115
},
116
{
117
name: 'World Championships',
118
start: '2016-10-16',
119
end: '2016-10-16'
120
}
121
]
122
},
123
{
124
name: 'Lars Petter Nordhaug',
125
description: 'Rider',
126
activities: [
127
{
128
name: 'Paris - Tours',
129
start: '2016-10-09',
130
end: '2016-10-09',
131
fill: ['#1A237E', '#FFFFFF', '#D50000']
132
},
133
{
134
name: 'Japan Cup',
135
start: '2016-10-23',
136
end: '2016-10-23',
137
fill: '#EF9A9A'
138
}
139
]
140
},
141
{
142
name: 'Nicolas Roche',
143
description: 'Rider',
144
activities: [
145
{
146
name: 'World Championships',
147
start: '2016-10-09',
148
end: '2016-10-09'
149
},
150
{
151
name: 'World Championships',
152
start: '2016-10-12',
153
end: '2016-10-12'
154
},
155
{
156
name: 'Abu Dhabi Tour',
157
start: '2016-10-20',
158
end: '2016-10-23',
159
fill: '#FFA000'
160
}
161
]
162
},
163
{
164
name: 'Geraint Thomas',
165
description: 'Rider',
166
activities: [
167
{
168
name: 'World Championships',
169
start: '2016-10-09',
170
end: '2016-10-09'
171
},
172
{
173
name: 'World Championships',
174
start: '2016-10-16',
175
end: '2016-10-16'
176
}
177
]
178
},
179
{
180
name: 'Danny van Poppel',
181
description: 'Rider',
182
activities: [
183
{
184
name: 'World Championships',
185
start: '2016-10-09',
186
end: '2016-10-09'
187
},
188
{
189
name: 'World Championships',
190
start: '2016-10-16',
191
end: '2016-10-16'
192
},
193
{
194
name: 'Abu Dhabi Tour',
195
start: '2016-10-20',
196
end: '2016-10-23',
197
fill: '#FFA000'
198
}
199
]
200
},
201
{
202
name: 'David Lopez',
203
description: 'Rider',
204
activities: [
205
{
206
name: 'Japan Cup',
207
start: '2016-10-23',
208
end: '2016-10-23',
209
fill: '#EF9A9A'
210
}
211
]
212
},
213
{
214
name: 'Xabier Zandio',
215
description: 'Rider',
216
activities: [
217
{
218
name: 'Japan Cup',
219
start: '2016-10-23',
220
end: '2016-10-23',
221
fill: '#EF9A9A'
222
}
223
]
224
}
225
];
226
}