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