highcharts-rails 4.2.7 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.markdown +34 -0
  3. data/Gemfile +4 -0
  4. data/Rakefile +53 -32
  5. data/app/assets/javascripts/highcharts.js +18775 -17176
  6. data/app/assets/javascripts/highcharts/highcharts-3d.js +1849 -1563
  7. data/app/assets/javascripts/highcharts/highcharts-more.js +2162 -1988
  8. data/app/assets/javascripts/highcharts/modules/accessibility.js +1005 -0
  9. data/app/assets/javascripts/highcharts/modules/annotations.js +408 -401
  10. data/app/assets/javascripts/highcharts/modules/boost.js +561 -546
  11. data/app/assets/javascripts/highcharts/modules/broken-axis.js +330 -324
  12. data/app/assets/javascripts/highcharts/modules/data.js +973 -965
  13. data/app/assets/javascripts/highcharts/modules/drilldown.js +783 -723
  14. data/app/assets/javascripts/highcharts/modules/exporting.js +864 -785
  15. data/app/assets/javascripts/highcharts/modules/funnel.js +290 -306
  16. data/app/assets/javascripts/highcharts/modules/heatmap.js +701 -645
  17. data/app/assets/javascripts/highcharts/modules/no-data-to-display.js +150 -132
  18. data/app/assets/javascripts/highcharts/modules/offline-exporting.js +414 -355
  19. data/app/assets/javascripts/highcharts/modules/overlapping-datalabels.js +164 -0
  20. data/app/assets/javascripts/highcharts/modules/series-label.js +473 -448
  21. data/app/assets/javascripts/highcharts/modules/solid-gauge.js +279 -271
  22. data/app/assets/javascripts/highcharts/modules/treemap.js +921 -886
  23. data/app/assets/javascripts/highcharts/themes/dark-blue.js +307 -244
  24. data/app/assets/javascripts/highcharts/themes/dark-green.js +303 -244
  25. data/app/assets/javascripts/highcharts/themes/dark-unica.js +231 -201
  26. data/app/assets/javascripts/highcharts/themes/gray.js +314 -245
  27. data/app/assets/javascripts/highcharts/themes/grid-light.js +91 -66
  28. data/app/assets/javascripts/highcharts/themes/grid.js +124 -96
  29. data/app/assets/javascripts/highcharts/themes/sand-signika.js +119 -94
  30. data/app/assets/javascripts/highcharts/themes/skies.js +108 -85
  31. data/lib/highcharts/version.rb +1 -1
  32. metadata +13 -14
  33. data/app/assets/javascripts/highcharts/adapters/standalone-framework.js +0 -1
  34. data/app/assets/javascripts/highcharts/modules/canvas-tools.js +0 -3115
  35. data/app/assets/javascripts/highcharts/modules/map.js +0 -2117
@@ -1,401 +1,408 @@
1
- (function (Highcharts, HighchartsAdapter) {
2
-
3
- var UNDEFINED,
4
- ALIGN_FACTOR,
5
- ALLOWED_SHAPES,
6
- Chart = Highcharts.Chart,
7
- extend = Highcharts.extend,
8
- each = Highcharts.each;
9
-
10
- ALLOWED_SHAPES = ["path", "rect", "circle"];
11
-
12
- ALIGN_FACTOR = {
13
- top: 0,
14
- left: 0,
15
- center: 0.5,
16
- middle: 0.5,
17
- bottom: 1,
18
- right: 1
19
- };
20
-
21
-
22
- // Highcharts helper methods
23
- var inArray = HighchartsAdapter.inArray,
24
- merge = Highcharts.merge;
25
-
26
- function defaultOptions(shapeType) {
27
- var shapeOptions,
28
- options;
29
-
30
- options = {
31
- xAxis: 0,
32
- yAxis: 0,
33
- title: {
34
- style: {},
35
- text: "",
36
- x: 0,
37
- y: 0
38
- },
39
- shape: {
40
- params: {
41
- stroke: "#000000",
42
- fill: "transparent",
43
- strokeWidth: 2
44
- }
45
- }
46
- };
47
-
48
- shapeOptions = {
49
- circle: {
50
- params: {
51
- x: 0,
52
- y: 0
53
- }
54
- }
55
- };
56
-
57
- if (shapeOptions[shapeType]) {
58
- options.shape = merge(options.shape, shapeOptions[shapeType]);
59
- }
60
-
61
- return options;
62
- }
63
-
64
- function isArray(obj) {
65
- return Object.prototype.toString.call(obj) === '[object Array]';
66
- }
67
-
68
- function isNumber(n) {
69
- return typeof n === 'number';
70
- }
71
-
72
- function defined(obj) {
73
- return obj !== UNDEFINED && obj !== null;
74
- }
75
-
76
- function translatePath(d, xAxis, yAxis, xOffset, yOffset) {
77
- var len = d.length,
78
- i = 0;
79
-
80
- while (i < len) {
81
- if (typeof d[i] === 'number' && typeof d[i + 1] === 'number') {
82
- d[i] = xAxis.toPixels(d[i]) - xOffset;
83
- d[i + 1] = yAxis.toPixels(d[i + 1]) - yOffset;
84
- i += 2;
85
- } else {
86
- i += 1;
87
- }
88
- }
89
-
90
- return d;
91
- }
92
-
93
-
94
- // Define annotation prototype
95
- var Annotation = function () {
96
- this.init.apply(this, arguments);
97
- };
98
- Annotation.prototype = {
99
- /*
100
- * Initialize the annotation
101
- */
102
- init: function (chart, options) {
103
- var shapeType = options.shape && options.shape.type;
104
-
105
- this.chart = chart;
106
- this.options = merge({}, defaultOptions(shapeType), options);
107
- },
108
-
109
- /*
110
- * Render the annotation
111
- */
112
- render: function (redraw) {
113
- var annotation = this,
114
- chart = this.chart,
115
- renderer = annotation.chart.renderer,
116
- group = annotation.group,
117
- title = annotation.title,
118
- shape = annotation.shape,
119
- options = annotation.options,
120
- titleOptions = options.title,
121
- shapeOptions = options.shape;
122
-
123
- if (!group) {
124
- group = annotation.group = renderer.g();
125
- }
126
-
127
-
128
- if (!shape && shapeOptions && inArray(shapeOptions.type, ALLOWED_SHAPES) !== -1) {
129
- shape = annotation.shape = renderer[options.shape.type](shapeOptions.params);
130
- shape.add(group);
131
- }
132
-
133
- if (!title && titleOptions) {
134
- title = annotation.title = renderer.label(titleOptions);
135
- title.add(group);
136
- }
137
-
138
- group.add(chart.annotations.group);
139
-
140
- // link annotations to point or series
141
- annotation.linkObjects();
142
-
143
- if (redraw !== false) {
144
- annotation.redraw();
145
- }
146
- },
147
-
148
- /*
149
- * Redraw the annotation title or shape after options update
150
- */
151
- redraw: function () {
152
- var options = this.options,
153
- chart = this.chart,
154
- group = this.group,
155
- title = this.title,
156
- shape = this.shape,
157
- linkedTo = this.linkedObject,
158
- xAxis = chart.xAxis[options.xAxis],
159
- yAxis = chart.yAxis[options.yAxis],
160
- width = options.width,
161
- height = options.height,
162
- anchorY = ALIGN_FACTOR[options.anchorY],
163
- anchorX = ALIGN_FACTOR[options.anchorX],
164
- resetBBox = false,
165
- shapeParams,
166
- linkType,
167
- series,
168
- param,
169
- bbox,
170
- x,
171
- y;
172
-
173
- if (linkedTo) {
174
- linkType = (linkedTo instanceof Highcharts.Point) ? 'point' :
175
- (linkedTo instanceof Highcharts.Series) ? 'series' : null;
176
-
177
- if (linkType === 'point') {
178
- options.xValue = linkedTo.x;
179
- options.yValue = linkedTo.y;
180
- series = linkedTo.series;
181
- } else if (linkType === 'series') {
182
- series = linkedTo;
183
- }
184
-
185
- if (group.visibility !== series.group.visibility) {
186
- group.attr({
187
- visibility: series.group.visibility
188
- });
189
- }
190
- }
191
-
192
-
193
- // Based on given options find annotation pixel position
194
- x = (defined(options.xValue) ? xAxis.toPixels(options.xValue + xAxis.minPointOffset) - xAxis.minPixelPadding : options.x);
195
- y = defined(options.yValue) ? yAxis.toPixels(options.yValue) : options.y;
196
-
197
- if (isNaN(x) || isNaN(y) || !isNumber(x) || !isNumber(y)) {
198
- return;
199
- }
200
-
201
-
202
- if (title) {
203
- title.attr(options.title);
204
- title.css(options.title.style);
205
- resetBBox = true;
206
- }
207
-
208
- if (shape) {
209
- shapeParams = extend({}, options.shape.params);
210
-
211
- if (options.units === 'values') {
212
- for (param in shapeParams) {
213
- if (inArray(param, ['width', 'x']) > -1) {
214
- shapeParams[param] = xAxis.translate(shapeParams[param]);
215
- } else if (inArray(param, ['height', 'y']) > -1) {
216
- shapeParams[param] = yAxis.translate(shapeParams[param]);
217
- }
218
- }
219
-
220
- if (shapeParams.width) {
221
- shapeParams.width -= xAxis.toPixels(0) - xAxis.left;
222
- }
223
-
224
- if (shapeParams.x) {
225
- shapeParams.x += xAxis.minPixelPadding;
226
- }
227
-
228
- if (options.shape.type === 'path') {
229
- translatePath(shapeParams.d, xAxis, yAxis, x, y);
230
- }
231
- }
232
-
233
- // move the center of the circle to shape x/y
234
- if (options.shape.type === 'circle') {
235
- shapeParams.x += shapeParams.r;
236
- shapeParams.y += shapeParams.r;
237
- }
238
-
239
- resetBBox = true;
240
- shape.attr(shapeParams);
241
- }
242
-
243
- group.bBox = null;
244
-
245
- // If annotation width or height is not defined in options use bounding box size
246
- if (!isNumber(width)) {
247
- bbox = group.getBBox();
248
- width = bbox.width;
249
- }
250
-
251
- if (!isNumber(height)) {
252
- // get bbox only if it wasn't set before
253
- if (!bbox) {
254
- bbox = group.getBBox();
255
- }
256
-
257
- height = bbox.height;
258
- }
259
-
260
- // Calculate anchor point
261
- if (!isNumber(anchorX)) {
262
- anchorX = ALIGN_FACTOR.center;
263
- }
264
-
265
- if (!isNumber(anchorY)) {
266
- anchorY = ALIGN_FACTOR.center;
267
- }
268
-
269
- // Translate group according to its dimension and anchor point
270
- x = x - width * anchorX;
271
- y = y - height * anchorY;
272
-
273
- if (chart.animation && defined(group.translateX) && defined(group.translateY)) {
274
- group.animate({
275
- translateX: x,
276
- translateY: y
277
- });
278
- } else {
279
- group.translate(x, y);
280
- }
281
- },
282
-
283
- /*
284
- * Destroy the annotation
285
- */
286
- destroy: function () {
287
- var annotation = this,
288
- chart = this.chart,
289
- allItems = chart.annotations.allItems,
290
- index = allItems.indexOf(annotation);
291
-
292
- if (index > -1) {
293
- allItems.splice(index, 1);
294
- }
295
-
296
- each(['title', 'shape', 'group'], function (element) {
297
- if (annotation[element]) {
298
- annotation[element].destroy();
299
- annotation[element] = null;
300
- }
301
- });
302
-
303
- annotation.group = annotation.title = annotation.shape = annotation.chart = annotation.options = null;
304
- },
305
-
306
- /*
307
- * Update the annotation with a given options
308
- */
309
- update: function (options, redraw) {
310
- extend(this.options, options);
311
-
312
- // update link to point or series
313
- this.linkObjects();
314
-
315
- this.render(redraw);
316
- },
317
-
318
- linkObjects: function () {
319
- var annotation = this,
320
- chart = annotation.chart,
321
- linkedTo = annotation.linkedObject,
322
- linkedId = linkedTo && (linkedTo.id || linkedTo.options.id),
323
- options = annotation.options,
324
- id = options.linkedTo;
325
-
326
- if (!defined(id)) {
327
- annotation.linkedObject = null;
328
- } else if (!defined(linkedTo) || id !== linkedId) {
329
- annotation.linkedObject = chart.get(id);
330
- }
331
- }
332
- };
333
-
334
-
335
- // Add annotations methods to chart prototype
336
- extend(Chart.prototype, {
337
- annotations: {
338
- /*
339
- * Unified method for adding annotations to the chart
340
- */
341
- add: function (options, redraw) {
342
- var annotations = this.allItems,
343
- chart = this.chart,
344
- item,
345
- len;
346
-
347
- if (!isArray(options)) {
348
- options = [options];
349
- }
350
-
351
- len = options.length;
352
-
353
- while (len--) {
354
- item = new Annotation(chart, options[len]);
355
- annotations.push(item);
356
- item.render(redraw);
357
- }
358
- },
359
-
360
- /**
361
- * Redraw all annotations, method used in chart events
362
- */
363
- redraw: function () {
364
- each(this.allItems, function (annotation) {
365
- annotation.redraw();
366
- });
367
- }
368
- }
369
- });
370
-
371
-
372
- // Initialize on chart load
373
- Chart.prototype.callbacks.push(function (chart) {
374
- var options = chart.options.annotations,
375
- group;
376
-
377
- group = chart.renderer.g("annotations");
378
- group.attr({
379
- zIndex: 7
380
- });
381
- group.add();
382
-
383
- // initialize empty array for annotations
384
- chart.annotations.allItems = [];
385
-
386
- // link chart object to annotations
387
- chart.annotations.chart = chart;
388
-
389
- // link annotations group element to the chart
390
- chart.annotations.group = group;
391
-
392
- if (isArray(options) && options.length > 0) {
393
- chart.annotations.add(chart.options.annotations);
394
- }
395
-
396
- // update annotations after chart redraw
397
- Highcharts.addEvent(chart, 'redraw', function () {
398
- chart.annotations.redraw();
399
- });
400
- });
401
- }(Highcharts, HighchartsAdapter));
1
+ /**
2
+ * @license Highcharts JS v5.0.0 (2016-09-29)
3
+ *
4
+ * (c) 2009-2016 Torstein Honsi
5
+ *
6
+ * License: www.highcharts.com/license
7
+ */
8
+ (function(factory) {
9
+ if (typeof module === 'object' && module.exports) {
10
+ module.exports = factory;
11
+ } else {
12
+ factory(Highcharts);
13
+ }
14
+ }(function(Highcharts) {
15
+ (function(H) {
16
+ /**
17
+ * (c) 2009-2016 Torstein Honsi
18
+ *
19
+ * License: www.highcharts.com/license
20
+ */
21
+ 'use strict';
22
+
23
+ var defined = H.defined,
24
+ isNumber = H.isNumber,
25
+ inArray = H.inArray,
26
+ isArray = H.isArray,
27
+ merge = H.merge,
28
+ Chart = H.Chart,
29
+ extend = H.extend,
30
+ each = H.each;
31
+
32
+ var ALIGN_FACTOR,
33
+ ALLOWED_SHAPES;
34
+
35
+ ALLOWED_SHAPES = ['path', 'rect', 'circle'];
36
+
37
+ ALIGN_FACTOR = {
38
+ top: 0,
39
+ left: 0,
40
+ center: 0.5,
41
+ middle: 0.5,
42
+ bottom: 1,
43
+ right: 1
44
+ };
45
+
46
+ function defaultOptions(shapeType) {
47
+ var shapeOptions,
48
+ options;
49
+
50
+ options = {
51
+ xAxis: 0,
52
+ yAxis: 0,
53
+ title: {
54
+ style: {},
55
+ text: '',
56
+ x: 0,
57
+ y: 0
58
+ },
59
+ shape: {
60
+ params: {
61
+ stroke: '#000000',
62
+ fill: 'transparent',
63
+ strokeWidth: 2
64
+ }
65
+ }
66
+ };
67
+
68
+ shapeOptions = {
69
+ circle: {
70
+ params: {
71
+ x: 0,
72
+ y: 0
73
+ }
74
+ }
75
+ };
76
+
77
+ if (shapeOptions[shapeType]) {
78
+ options.shape = merge(options.shape, shapeOptions[shapeType]);
79
+ }
80
+
81
+ return options;
82
+ }
83
+
84
+ function translatePath(d, xAxis, yAxis, xOffset, yOffset) {
85
+ var len = d.length,
86
+ i = 0;
87
+
88
+ while (i < len) {
89
+ if (isNumber(d[i]) && isNumber(d[i + 1])) {
90
+ d[i] = xAxis.toPixels(d[i]) - xOffset;
91
+ d[i + 1] = yAxis.toPixels(d[i + 1]) - yOffset;
92
+ i += 2;
93
+ } else {
94
+ i += 1;
95
+ }
96
+ }
97
+
98
+ return d;
99
+ }
100
+
101
+
102
+ // Define annotation prototype
103
+ var Annotation = function() {
104
+ this.init.apply(this, arguments);
105
+ };
106
+ Annotation.prototype = {
107
+ /*
108
+ * Initialize the annotation
109
+ */
110
+ init: function(chart, options) {
111
+ var shapeType = options.shape && options.shape.type;
112
+
113
+ this.chart = chart;
114
+ this.options = merge({}, defaultOptions(shapeType), options);
115
+ },
116
+
117
+ /*
118
+ * Render the annotation
119
+ */
120
+ render: function(redraw) {
121
+ var annotation = this,
122
+ chart = this.chart,
123
+ renderer = annotation.chart.renderer,
124
+ group = annotation.group,
125
+ title = annotation.title,
126
+ shape = annotation.shape,
127
+ options = annotation.options,
128
+ titleOptions = options.title,
129
+ shapeOptions = options.shape;
130
+
131
+ if (!group) {
132
+ group = annotation.group = renderer.g();
133
+ }
134
+
135
+
136
+ if (!shape && shapeOptions && inArray(shapeOptions.type, ALLOWED_SHAPES) !== -1) {
137
+ shape = annotation.shape = renderer[options.shape.type](shapeOptions.params);
138
+ shape.add(group);
139
+ }
140
+
141
+ if (!title && titleOptions) {
142
+ title = annotation.title = renderer.label(titleOptions);
143
+ title.add(group);
144
+ }
145
+
146
+ group.add(chart.annotations.group);
147
+
148
+ // link annotations to point or series
149
+ annotation.linkObjects();
150
+
151
+ if (redraw !== false) {
152
+ annotation.redraw();
153
+ }
154
+ },
155
+
156
+ /*
157
+ * Redraw the annotation title or shape after options update
158
+ */
159
+ redraw: function() {
160
+ var options = this.options,
161
+ chart = this.chart,
162
+ group = this.group,
163
+ title = this.title,
164
+ shape = this.shape,
165
+ linkedTo = this.linkedObject,
166
+ xAxis = chart.xAxis[options.xAxis],
167
+ yAxis = chart.yAxis[options.yAxis],
168
+ width = options.width,
169
+ height = options.height,
170
+ anchorY = ALIGN_FACTOR[options.anchorY],
171
+ anchorX = ALIGN_FACTOR[options.anchorX],
172
+ shapeParams,
173
+ linkType,
174
+ series,
175
+ param,
176
+ bbox,
177
+ x,
178
+ y;
179
+
180
+ if (linkedTo) {
181
+ linkType = (linkedTo instanceof H.Point) ? 'point' :
182
+ (linkedTo instanceof H.Series) ? 'series' : null;
183
+
184
+ if (linkType === 'point') {
185
+ options.xValue = linkedTo.x;
186
+ options.yValue = linkedTo.y;
187
+ series = linkedTo.series;
188
+ } else if (linkType === 'series') {
189
+ series = linkedTo;
190
+ }
191
+
192
+ if (group.visibility !== series.group.visibility) {
193
+ group.attr({
194
+ visibility: series.group.visibility
195
+ });
196
+ }
197
+ }
198
+
199
+
200
+ // Based on given options find annotation pixel position
201
+ x = (defined(options.xValue) ? xAxis.toPixels(options.xValue + xAxis.minPointOffset) - xAxis.minPixelPadding : options.x);
202
+ y = defined(options.yValue) ? yAxis.toPixels(options.yValue) : options.y;
203
+
204
+ if (!isNumber(x) || !isNumber(y)) {
205
+ return;
206
+ }
207
+
208
+
209
+ if (title) {
210
+ title.attr(options.title);
211
+ title.css(options.title.style);
212
+ }
213
+
214
+ if (shape) {
215
+ shapeParams = extend({}, options.shape.params);
216
+
217
+ if (options.units === 'values') {
218
+ for (param in shapeParams) {
219
+ if (inArray(param, ['width', 'x']) > -1) {
220
+ shapeParams[param] = xAxis.translate(shapeParams[param]);
221
+ } else if (inArray(param, ['height', 'y']) > -1) {
222
+ shapeParams[param] = yAxis.translate(shapeParams[param]);
223
+ }
224
+ }
225
+
226
+ if (shapeParams.width) {
227
+ shapeParams.width -= xAxis.toPixels(0) - xAxis.left;
228
+ }
229
+
230
+ if (shapeParams.x) {
231
+ shapeParams.x += xAxis.minPixelPadding;
232
+ }
233
+
234
+ if (options.shape.type === 'path') {
235
+ translatePath(shapeParams.d, xAxis, yAxis, x, y);
236
+ }
237
+ }
238
+
239
+ // move the center of the circle to shape x/y
240
+ if (options.shape.type === 'circle') {
241
+ shapeParams.x += shapeParams.r;
242
+ shapeParams.y += shapeParams.r;
243
+ }
244
+
245
+ shape.attr(shapeParams);
246
+ }
247
+
248
+ group.bBox = null;
249
+
250
+ // If annotation width or height is not defined in options use bounding box size
251
+ if (!isNumber(width)) {
252
+ bbox = group.getBBox();
253
+ width = bbox.width;
254
+ }
255
+
256
+ if (!isNumber(height)) {
257
+ // get bbox only if it wasn't set before
258
+ if (!bbox) {
259
+ bbox = group.getBBox();
260
+ }
261
+
262
+ height = bbox.height;
263
+ }
264
+
265
+ // Calculate anchor point
266
+ if (!isNumber(anchorX)) {
267
+ anchorX = ALIGN_FACTOR.center;
268
+ }
269
+
270
+ if (!isNumber(anchorY)) {
271
+ anchorY = ALIGN_FACTOR.center;
272
+ }
273
+
274
+ // Translate group according to its dimension and anchor point
275
+ x = x - width * anchorX;
276
+ y = y - height * anchorY;
277
+
278
+ if (defined(group.translateX) && defined(group.translateY)) {
279
+ group.animate({
280
+ translateX: x,
281
+ translateY: y
282
+ });
283
+ } else {
284
+ group.translate(x, y);
285
+ }
286
+ },
287
+
288
+ /*
289
+ * Destroy the annotation
290
+ */
291
+ destroy: function() {
292
+ var annotation = this,
293
+ chart = this.chart,
294
+ allItems = chart.annotations.allItems,
295
+ index = allItems.indexOf(annotation);
296
+
297
+ if (index > -1) {
298
+ allItems.splice(index, 1);
299
+ }
300
+
301
+ each(['title', 'shape', 'group'], function(element) {
302
+ if (annotation[element]) {
303
+ annotation[element].destroy();
304
+ annotation[element] = null;
305
+ }
306
+ });
307
+
308
+ annotation.group = annotation.title = annotation.shape = annotation.chart = annotation.options = null;
309
+ },
310
+
311
+ /*
312
+ * Update the annotation with a given options
313
+ */
314
+ update: function(options, redraw) {
315
+ extend(this.options, options);
316
+
317
+ // update link to point or series
318
+ this.linkObjects();
319
+
320
+ this.render(redraw);
321
+ },
322
+
323
+ linkObjects: function() {
324
+ var annotation = this,
325
+ chart = annotation.chart,
326
+ linkedTo = annotation.linkedObject,
327
+ linkedId = linkedTo && (linkedTo.id || linkedTo.options.id),
328
+ options = annotation.options,
329
+ id = options.linkedTo;
330
+
331
+ if (!defined(id)) {
332
+ annotation.linkedObject = null;
333
+ } else if (!defined(linkedTo) || id !== linkedId) {
334
+ annotation.linkedObject = chart.get(id);
335
+ }
336
+ }
337
+ };
338
+
339
+
340
+ // Add annotations methods to chart prototype
341
+ extend(Chart.prototype, {
342
+ annotations: {
343
+ /*
344
+ * Unified method for adding annotations to the chart
345
+ */
346
+ add: function(options, redraw) {
347
+ var annotations = this.allItems,
348
+ chart = this.chart,
349
+ item,
350
+ len;
351
+
352
+ if (!isArray(options)) {
353
+ options = [options];
354
+ }
355
+
356
+ len = options.length;
357
+
358
+ while (len--) {
359
+ item = new Annotation(chart, options[len]);
360
+ annotations.push(item);
361
+ item.render(redraw);
362
+ }
363
+ },
364
+
365
+ /**
366
+ * Redraw all annotations, method used in chart events
367
+ */
368
+ redraw: function() {
369
+ each(this.allItems, function(annotation) {
370
+ annotation.redraw();
371
+ });
372
+ }
373
+ }
374
+ });
375
+
376
+
377
+ // Initialize on chart load
378
+ Chart.prototype.callbacks.push(function(chart) {
379
+ var options = chart.options.annotations,
380
+ group;
381
+
382
+ group = chart.renderer.g('annotations');
383
+ group.attr({
384
+ zIndex: 7
385
+ });
386
+ group.add();
387
+
388
+ // initialize empty array for annotations
389
+ chart.annotations.allItems = [];
390
+
391
+ // link chart object to annotations
392
+ chart.annotations.chart = chart;
393
+
394
+ // link annotations group element to the chart
395
+ chart.annotations.group = group;
396
+
397
+ if (isArray(options) && options.length > 0) {
398
+ chart.annotations.add(chart.options.annotations);
399
+ }
400
+
401
+ // update annotations after chart redraw
402
+ H.addEvent(chart, 'redraw', function() {
403
+ chart.annotations.redraw();
404
+ });
405
+ });
406
+
407
+ }(Highcharts));
408
+ }));