corrade-nucleus-nucleons – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /** |
11 | office | 2 | * @license Highcharts JS v5.0.12 (2017-05-24) |
1 | office | 3 | * |
4 | * (c) 2014 Highsoft AS |
||
5 | * Authors: Jon Arild Nygard / Oystein Moseng |
||
6 | * |
||
7 | * License: www.highcharts.com/license |
||
8 | */ |
||
9 | 'use strict'; |
||
10 | (function(factory) { |
||
11 | if (typeof module === 'object' && module.exports) { |
||
12 | module.exports = factory; |
||
13 | } else { |
||
14 | factory(Highcharts); |
||
15 | } |
||
16 | }(function(Highcharts) { |
||
17 | (function(H) { |
||
18 | /** |
||
19 | * (c) 2014 Highsoft AS |
||
20 | * Authors: Jon Arild Nygard / Oystein Moseng |
||
21 | * |
||
22 | * License: www.highcharts.com/license |
||
23 | */ |
||
24 | |||
25 | var seriesType = H.seriesType, |
||
26 | seriesTypes = H.seriesTypes, |
||
27 | map = H.map, |
||
28 | merge = H.merge, |
||
29 | extend = H.extend, |
||
30 | noop = H.noop, |
||
31 | each = H.each, |
||
32 | grep = H.grep, |
||
33 | isNumber = H.isNumber, |
||
34 | isString = H.isString, |
||
35 | pick = H.pick, |
||
36 | Series = H.Series, |
||
37 | stableSort = H.stableSort, |
||
38 | color = H.Color, |
||
39 | eachObject = function(list, func, context) { |
||
40 | context = context || this; |
||
11 | office | 41 | H.objectEach(list, function(val, key) { |
42 | func.call(context, val, key, list); |
||
43 | }); |
||
1 | office | 44 | }, |
45 | reduce = function(arr, func, previous, context) { |
||
46 | context = context || this; |
||
47 | arr = arr || []; // @note should each be able to handle empty values automatically? |
||
48 | each(arr, function(current, i) { |
||
49 | previous = func.call(context, previous, current, i, arr); |
||
50 | }); |
||
51 | return previous; |
||
52 | }, |
||
53 | // @todo find correct name for this function. |
||
54 | // @todo Similar to reduce, this function is likely redundant |
||
55 | recursive = function(item, func, context) { |
||
56 | var next; |
||
57 | context = context || this; |
||
58 | next = func.call(context, item); |
||
59 | if (next !== false) { |
||
60 | recursive(next, func, context); |
||
61 | } |
||
62 | }; |
||
63 | |||
64 | // The Treemap series type |
||
65 | seriesType('treemap', 'scatter', { |
||
66 | showInLegend: false, |
||
67 | marker: false, |
||
68 | dataLabels: { |
||
69 | enabled: true, |
||
70 | defer: false, |
||
71 | verticalAlign: 'middle', |
||
72 | formatter: function() { // #2945 |
||
73 | return this.point.name || this.point.id; |
||
74 | }, |
||
75 | inside: true |
||
76 | }, |
||
77 | tooltip: { |
||
78 | headerFormat: '', |
||
79 | pointFormat: '<b>{point.name}</b>: {point.value}</b><br/>' |
||
80 | }, |
||
81 | ignoreHiddenPoint: true, |
||
82 | layoutAlgorithm: 'sliceAndDice', |
||
83 | layoutStartingDirection: 'vertical', |
||
84 | alternateStartingDirection: false, |
||
85 | levelIsConstant: true, |
||
86 | drillUpButton: { |
||
87 | position: { |
||
88 | align: 'right', |
||
89 | x: -10, |
||
90 | y: 10 |
||
91 | } |
||
92 | }, |
||
93 | |||
94 | |||
95 | // Prototype members |
||
96 | }, { |
||
97 | pointArrayMap: ['value'], |
||
98 | axisTypes: seriesTypes.heatmap ? ['xAxis', 'yAxis', 'colorAxis'] : ['xAxis', 'yAxis'], |
||
99 | optionalAxis: 'colorAxis', |
||
100 | getSymbol: noop, |
||
101 | parallelArrays: ['x', 'y', 'value', 'colorValue'], |
||
102 | colorKey: 'colorValue', // Point color option key |
||
103 | translateColors: seriesTypes.heatmap && seriesTypes.heatmap.prototype.translateColors, |
||
104 | trackerGroups: ['group', 'dataLabelsGroup'], |
||
105 | /** |
||
106 | * Creates an object map from parent id to childrens index. |
||
107 | * @param {Array} data List of points set in options. |
||
108 | * @param {string} data[].parent Parent id of point. |
||
109 | * @param {Array} ids List of all point ids. |
||
110 | * @return {Object} Map from parent id to children index in data. |
||
111 | */ |
||
112 | getListOfParents: function(data, ids) { |
||
113 | var listOfParents = reduce(data, function(prev, curr, i) { |
||
114 | var parent = pick(curr.parent, ''); |
||
115 | if (prev[parent] === undefined) { |
||
116 | prev[parent] = []; |
||
117 | } |
||
118 | prev[parent].push(i); |
||
119 | return prev; |
||
120 | }, {}); |
||
121 | |||
122 | // If parent does not exist, hoist parent to root of tree. |
||
123 | eachObject(listOfParents, function(children, parent, list) { |
||
124 | if ((parent !== '') && (H.inArray(parent, ids) === -1)) { |
||
125 | each(children, function(child) { |
||
126 | list[''].push(child); |
||
127 | }); |
||
128 | delete list[parent]; |
||
129 | } |
||
130 | }); |
||
131 | return listOfParents; |
||
132 | }, |
||
133 | /** |
||
134 | * Creates a tree structured object from the series points |
||
135 | */ |
||
136 | getTree: function() { |
||
137 | var series = this, |
||
138 | allIds = map(this.data, function(d) { |
||
139 | return d.id; |
||
140 | }), |
||
141 | parentList = series.getListOfParents(this.data, allIds); |
||
142 | |||
143 | series.nodeMap = []; |
||
144 | return series.buildNode('', -1, 0, parentList, null); |
||
145 | }, |
||
146 | init: function(chart, options) { |
||
147 | var series = this; |
||
148 | Series.prototype.init.call(series, chart, options); |
||
149 | if (series.options.allowDrillToNode) { |
||
150 | H.addEvent(series, 'click', series.onClickDrillToNode); |
||
151 | } |
||
152 | }, |
||
153 | buildNode: function(id, i, level, list, parent) { |
||
154 | var series = this, |
||
155 | children = [], |
||
156 | point = series.points[i], |
||
157 | node, |
||
158 | child; |
||
159 | |||
160 | // Actions |
||
161 | each((list[id] || []), function(i) { |
||
162 | child = series.buildNode(series.points[i].id, i, (level + 1), list, id); |
||
163 | children.push(child); |
||
164 | }); |
||
165 | node = { |
||
166 | id: id, |
||
167 | i: i, |
||
168 | children: children, |
||
169 | level: level, |
||
170 | parent: parent, |
||
171 | visible: false // @todo move this to better location |
||
172 | }; |
||
173 | series.nodeMap[node.id] = node; |
||
174 | if (point) { |
||
175 | point.node = node; |
||
176 | } |
||
177 | return node; |
||
178 | }, |
||
179 | setTreeValues: function(tree) { |
||
180 | var series = this, |
||
181 | options = series.options, |
||
182 | childrenTotal = 0, |
||
183 | children = [], |
||
184 | val, |
||
185 | point = series.points[tree.i]; |
||
186 | // Parents of the root node is by default visible |
||
187 | recursive(series.nodeMap[series.rootNode], function(node) { |
||
188 | var next = false, |
||
189 | p = node.parent; |
||
190 | node.visible = true; |
||
191 | if (p || p === '') { |
||
192 | next = series.nodeMap[p]; |
||
193 | } |
||
194 | return next; |
||
195 | }); |
||
196 | // Children of the root node is by default visible |
||
197 | recursive(series.nodeMap[series.rootNode].children, function(children) { |
||
198 | var next = false; |
||
199 | each(children, function(child) { |
||
200 | child.visible = true; |
||
201 | if (child.children.length) { |
||
202 | next = (next || []).concat(child.children); |
||
203 | } |
||
204 | }); |
||
205 | return next; |
||
206 | }); |
||
207 | |||
208 | // First give the children some values |
||
209 | each(tree.children, function(child) { |
||
210 | child = series.setTreeValues(child); |
||
211 | children.push(child); |
||
212 | |||
213 | if (!child.ignore) { |
||
214 | childrenTotal += child.val; |
||
215 | } else { |
||
216 | // @todo Add predicate to avoid looping already ignored children |
||
217 | recursive(child.children, function(children) { |
||
218 | var next = false; |
||
219 | each(children, function(node) { |
||
220 | extend(node, { |
||
221 | ignore: true, |
||
222 | isLeaf: false, |
||
223 | visible: false |
||
224 | }); |
||
225 | if (node.children.length) { |
||
226 | next = (next || []).concat(node.children); |
||
227 | } |
||
228 | }); |
||
229 | return next; |
||
230 | }); |
||
231 | } |
||
232 | }); |
||
233 | // Sort the children |
||
234 | stableSort(children, function(a, b) { |
||
235 | return a.sortIndex - b.sortIndex; |
||
236 | }); |
||
237 | // Set the values |
||
238 | val = pick(point && point.options.value, childrenTotal); |
||
239 | if (point) { |
||
240 | point.value = val; |
||
241 | } |
||
242 | extend(tree, { |
||
243 | children: children, |
||
244 | childrenTotal: childrenTotal, |
||
245 | // Ignore this node if point is not visible |
||
246 | ignore: !(pick(point && point.visible, true) && (val > 0)), |
||
247 | isLeaf: tree.visible && !childrenTotal, |
||
248 | levelDynamic: (options.levelIsConstant ? tree.level : (tree.level - series.nodeMap[series.rootNode].level)), |
||
249 | name: pick(point && point.name, ''), |
||
250 | sortIndex: pick(point && point.sortIndex, -val), |
||
251 | val: val |
||
252 | }); |
||
253 | return tree; |
||
254 | }, |
||
255 | /** |
||
256 | * Recursive function which calculates the area for all children of a node. |
||
257 | * @param {Object} node The node which is parent to the children. |
||
258 | * @param {Object} area The rectangular area of the parent. |
||
259 | */ |
||
260 | calculateChildrenAreas: function(parent, area) { |
||
261 | var series = this, |
||
262 | options = series.options, |
||
263 | level = this.levelMap[parent.levelDynamic + 1], |
||
264 | algorithm = pick((series[level && level.layoutAlgorithm] && level.layoutAlgorithm), options.layoutAlgorithm), |
||
265 | alternate = options.alternateStartingDirection, |
||
266 | childrenValues = [], |
||
267 | children; |
||
268 | |||
269 | // Collect all children which should be included |
||
270 | children = grep(parent.children, function(n) { |
||
271 | return !n.ignore; |
||
272 | }); |
||
273 | |||
274 | if (level && level.layoutStartingDirection) { |
||
275 | area.direction = level.layoutStartingDirection === 'vertical' ? 0 : 1; |
||
276 | } |
||
277 | childrenValues = series[algorithm](area, children); |
||
278 | each(children, function(child, index) { |
||
279 | var values = childrenValues[index]; |
||
280 | child.values = merge(values, { |
||
281 | val: child.childrenTotal, |
||
282 | direction: (alternate ? 1 - area.direction : area.direction) |
||
283 | }); |
||
284 | child.pointValues = merge(values, { |
||
285 | x: (values.x / series.axisRatio), |
||
286 | width: (values.width / series.axisRatio) |
||
287 | }); |
||
288 | // If node has children, then call method recursively |
||
289 | if (child.children.length) { |
||
290 | series.calculateChildrenAreas(child, child.values); |
||
291 | } |
||
292 | }); |
||
293 | }, |
||
294 | setPointValues: function() { |
||
295 | var series = this, |
||
296 | xAxis = series.xAxis, |
||
297 | yAxis = series.yAxis; |
||
298 | each(series.points, function(point) { |
||
299 | var node = point.node, |
||
300 | values = node.pointValues, |
||
301 | x1, |
||
302 | x2, |
||
303 | y1, |
||
304 | y2, |
||
305 | crispCorr = 0; |
||
306 | |||
307 | |||
308 | |||
309 | // Points which is ignored, have no values. |
||
310 | if (values && node.visible) { |
||
311 | x1 = Math.round(xAxis.translate(values.x, 0, 0, 0, 1)) - crispCorr; |
||
312 | x2 = Math.round(xAxis.translate(values.x + values.width, 0, 0, 0, 1)) - crispCorr; |
||
313 | y1 = Math.round(yAxis.translate(values.y, 0, 0, 0, 1)) - crispCorr; |
||
314 | y2 = Math.round(yAxis.translate(values.y + values.height, 0, 0, 0, 1)) - crispCorr; |
||
315 | // Set point values |
||
316 | point.shapeType = 'rect'; |
||
317 | point.shapeArgs = { |
||
318 | x: Math.min(x1, x2), |
||
319 | y: Math.min(y1, y2), |
||
320 | width: Math.abs(x2 - x1), |
||
321 | height: Math.abs(y2 - y1) |
||
322 | }; |
||
323 | point.plotX = point.shapeArgs.x + (point.shapeArgs.width / 2); |
||
324 | point.plotY = point.shapeArgs.y + (point.shapeArgs.height / 2); |
||
325 | } else { |
||
326 | // Reset visibility |
||
327 | delete point.plotX; |
||
328 | delete point.plotY; |
||
329 | } |
||
330 | }); |
||
331 | }, |
||
332 | setColorRecursive: function(node, color, colorIndex) { |
||
333 | var series = this, |
||
334 | point, |
||
335 | level; |
||
336 | if (node) { |
||
337 | point = series.points[node.i]; |
||
338 | level = series.levelMap[node.levelDynamic]; |
||
339 | // Select either point color, level color or inherited color. |
||
340 | color = pick( |
||
341 | point && point.options.color, |
||
342 | level && level.color, |
||
343 | color, |
||
344 | series.color |
||
345 | ); |
||
346 | colorIndex = pick( |
||
347 | point && point.options.colorIndex, |
||
348 | level && level.colorIndex, |
||
349 | colorIndex, |
||
350 | series.colorIndex |
||
351 | ); |
||
352 | |||
353 | if (point) { |
||
354 | point.color = color; |
||
355 | point.colorIndex = colorIndex; |
||
356 | } |
||
357 | |||
358 | // Do it all again with the children |
||
359 | if (node.children.length) { |
||
360 | each(node.children, function(child) { |
||
361 | series.setColorRecursive(child, color, colorIndex); |
||
362 | }); |
||
363 | } |
||
364 | } |
||
365 | }, |
||
366 | algorithmGroup: function(h, w, d, p) { |
||
367 | this.height = h; |
||
368 | this.width = w; |
||
369 | this.plot = p; |
||
370 | this.direction = d; |
||
371 | this.startDirection = d; |
||
372 | this.total = 0; |
||
373 | this.nW = 0; |
||
374 | this.lW = 0; |
||
375 | this.nH = 0; |
||
376 | this.lH = 0; |
||
377 | this.elArr = []; |
||
378 | this.lP = { |
||
379 | total: 0, |
||
380 | lH: 0, |
||
381 | nH: 0, |
||
382 | lW: 0, |
||
383 | nW: 0, |
||
384 | nR: 0, |
||
385 | lR: 0, |
||
386 | aspectRatio: function(w, h) { |
||
387 | return Math.max((w / h), (h / w)); |
||
388 | } |
||
389 | }; |
||
390 | this.addElement = function(el) { |
||
391 | this.lP.total = this.elArr[this.elArr.length - 1]; |
||
392 | this.total = this.total + el; |
||
393 | if (this.direction === 0) { |
||
394 | // Calculate last point old aspect ratio |
||
395 | this.lW = this.nW; |
||
396 | this.lP.lH = this.lP.total / this.lW; |
||
397 | this.lP.lR = this.lP.aspectRatio(this.lW, this.lP.lH); |
||
398 | // Calculate last point new aspect ratio |
||
399 | this.nW = this.total / this.height; |
||
400 | this.lP.nH = this.lP.total / this.nW; |
||
401 | this.lP.nR = this.lP.aspectRatio(this.nW, this.lP.nH); |
||
402 | } else { |
||
403 | // Calculate last point old aspect ratio |
||
404 | this.lH = this.nH; |
||
405 | this.lP.lW = this.lP.total / this.lH; |
||
406 | this.lP.lR = this.lP.aspectRatio(this.lP.lW, this.lH); |
||
407 | // Calculate last point new aspect ratio |
||
408 | this.nH = this.total / this.width; |
||
409 | this.lP.nW = this.lP.total / this.nH; |
||
410 | this.lP.nR = this.lP.aspectRatio(this.lP.nW, this.nH); |
||
411 | } |
||
412 | this.elArr.push(el); |
||
413 | }; |
||
414 | this.reset = function() { |
||
415 | this.nW = 0; |
||
416 | this.lW = 0; |
||
417 | this.elArr = []; |
||
418 | this.total = 0; |
||
419 | }; |
||
420 | }, |
||
421 | algorithmCalcPoints: function(directionChange, last, group, childrenArea) { |
||
422 | var pX, |
||
423 | pY, |
||
424 | pW, |
||
425 | pH, |
||
426 | gW = group.lW, |
||
427 | gH = group.lH, |
||
428 | plot = group.plot, |
||
429 | keep, |
||
430 | i = 0, |
||
431 | end = group.elArr.length - 1; |
||
432 | if (last) { |
||
433 | gW = group.nW; |
||
434 | gH = group.nH; |
||
435 | } else { |
||
436 | keep = group.elArr[group.elArr.length - 1]; |
||
437 | } |
||
438 | each(group.elArr, function(p) { |
||
439 | if (last || (i < end)) { |
||
440 | if (group.direction === 0) { |
||
441 | pX = plot.x; |
||
442 | pY = plot.y; |
||
443 | pW = gW; |
||
444 | pH = p / pW; |
||
445 | } else { |
||
446 | pX = plot.x; |
||
447 | pY = plot.y; |
||
448 | pH = gH; |
||
449 | pW = p / pH; |
||
450 | } |
||
451 | childrenArea.push({ |
||
452 | x: pX, |
||
453 | y: pY, |
||
454 | width: pW, |
||
455 | height: pH |
||
456 | }); |
||
457 | if (group.direction === 0) { |
||
458 | plot.y = plot.y + pH; |
||
459 | } else { |
||
460 | plot.x = plot.x + pW; |
||
461 | } |
||
462 | } |
||
463 | i = i + 1; |
||
464 | }); |
||
465 | // Reset variables |
||
466 | group.reset(); |
||
467 | if (group.direction === 0) { |
||
468 | group.width = group.width - gW; |
||
469 | } else { |
||
470 | group.height = group.height - gH; |
||
471 | } |
||
472 | plot.y = plot.parent.y + (plot.parent.height - group.height); |
||
473 | plot.x = plot.parent.x + (plot.parent.width - group.width); |
||
474 | if (directionChange) { |
||
475 | group.direction = 1 - group.direction; |
||
476 | } |
||
477 | // If not last, then add uncalculated element |
||
478 | if (!last) { |
||
479 | group.addElement(keep); |
||
480 | } |
||
481 | }, |
||
482 | algorithmLowAspectRatio: function(directionChange, parent, children) { |
||
483 | var childrenArea = [], |
||
484 | series = this, |
||
485 | pTot, |
||
486 | plot = { |
||
487 | x: parent.x, |
||
488 | y: parent.y, |
||
489 | parent: parent |
||
490 | }, |
||
491 | direction = parent.direction, |
||
492 | i = 0, |
||
493 | end = children.length - 1, |
||
494 | group = new this.algorithmGroup(parent.height, parent.width, direction, plot); // eslint-disable-line new-cap |
||
495 | // Loop through and calculate all areas |
||
496 | each(children, function(child) { |
||
497 | pTot = (parent.width * parent.height) * (child.val / parent.val); |
||
498 | group.addElement(pTot); |
||
499 | if (group.lP.nR > group.lP.lR) { |
||
500 | series.algorithmCalcPoints(directionChange, false, group, childrenArea, plot); |
||
501 | } |
||
502 | // If last child, then calculate all remaining areas |
||
503 | if (i === end) { |
||
504 | series.algorithmCalcPoints(directionChange, true, group, childrenArea, plot); |
||
505 | } |
||
506 | i = i + 1; |
||
507 | }); |
||
508 | return childrenArea; |
||
509 | }, |
||
510 | algorithmFill: function(directionChange, parent, children) { |
||
511 | var childrenArea = [], |
||
512 | pTot, |
||
513 | direction = parent.direction, |
||
514 | x = parent.x, |
||
515 | y = parent.y, |
||
516 | width = parent.width, |
||
517 | height = parent.height, |
||
518 | pX, |
||
519 | pY, |
||
520 | pW, |
||
521 | pH; |
||
522 | each(children, function(child) { |
||
523 | pTot = (parent.width * parent.height) * (child.val / parent.val); |
||
524 | pX = x; |
||
525 | pY = y; |
||
526 | if (direction === 0) { |
||
527 | pH = height; |
||
528 | pW = pTot / pH; |
||
529 | width = width - pW; |
||
530 | x = x + pW; |
||
531 | } else { |
||
532 | pW = width; |
||
533 | pH = pTot / pW; |
||
534 | height = height - pH; |
||
535 | y = y + pH; |
||
536 | } |
||
537 | childrenArea.push({ |
||
538 | x: pX, |
||
539 | y: pY, |
||
540 | width: pW, |
||
541 | height: pH |
||
542 | }); |
||
543 | if (directionChange) { |
||
544 | direction = 1 - direction; |
||
545 | } |
||
546 | }); |
||
547 | return childrenArea; |
||
548 | }, |
||
549 | strip: function(parent, children) { |
||
550 | return this.algorithmLowAspectRatio(false, parent, children); |
||
551 | }, |
||
552 | squarified: function(parent, children) { |
||
553 | return this.algorithmLowAspectRatio(true, parent, children); |
||
554 | }, |
||
555 | sliceAndDice: function(parent, children) { |
||
556 | return this.algorithmFill(true, parent, children); |
||
557 | }, |
||
558 | stripes: function(parent, children) { |
||
559 | return this.algorithmFill(false, parent, children); |
||
560 | }, |
||
561 | translate: function() { |
||
562 | var series = this, |
||
563 | rootId = series.rootNode = pick(series.rootNode, series.options.rootId, ''), |
||
564 | rootNode, |
||
565 | pointValues, |
||
566 | seriesArea, |
||
567 | tree, |
||
568 | val; |
||
569 | |||
570 | // Call prototype function |
||
571 | Series.prototype.translate.call(series); |
||
572 | // Create a object map from level to options |
||
573 | series.levelMap = reduce(series.options.levels, function(arr, item) { |
||
574 | arr[item.level] = item; |
||
575 | return arr; |
||
576 | }, {}); |
||
577 | tree = series.tree = series.getTree(); // @todo Only if series.isDirtyData is true |
||
578 | rootNode = series.nodeMap[rootId]; |
||
579 | if ( |
||
580 | rootId !== '' && |
||
581 | (!rootNode || !rootNode.children.length) |
||
582 | ) { |
||
583 | series.drillToNode('', false); |
||
584 | rootId = series.rootNode; |
||
585 | rootNode = series.nodeMap[rootId]; |
||
586 | } |
||
587 | series.setTreeValues(tree); |
||
588 | |||
589 | // Calculate plotting values. |
||
590 | series.axisRatio = (series.xAxis.len / series.yAxis.len); |
||
591 | series.nodeMap[''].pointValues = pointValues = { |
||
592 | x: 0, |
||
593 | y: 0, |
||
594 | width: 100, |
||
595 | height: 100 |
||
596 | }; |
||
597 | series.nodeMap[''].values = seriesArea = merge(pointValues, { |
||
598 | width: (pointValues.width * series.axisRatio), |
||
599 | direction: (series.options.layoutStartingDirection === 'vertical' ? 0 : 1), |
||
600 | val: tree.val |
||
601 | }); |
||
602 | series.calculateChildrenAreas(tree, seriesArea); |
||
603 | |||
604 | // Logic for point colors |
||
605 | if (series.colorAxis) { |
||
606 | series.translateColors(); |
||
607 | } else if (!series.options.colorByPoint) { |
||
608 | series.setColorRecursive(series.tree); |
||
609 | } |
||
610 | |||
611 | // Update axis extremes according to the root node. |
||
612 | if (series.options.allowDrillToNode) { |
||
613 | val = rootNode.pointValues; |
||
614 | series.xAxis.setExtremes(val.x, val.x + val.width, false); |
||
615 | series.yAxis.setExtremes(val.y, val.y + val.height, false); |
||
616 | series.xAxis.setScale(); |
||
617 | series.yAxis.setScale(); |
||
618 | } |
||
619 | |||
620 | // Assign values to points. |
||
621 | series.setPointValues(); |
||
622 | }, |
||
623 | /** |
||
624 | * Extend drawDataLabels with logic to handle custom options related to the treemap series: |
||
625 | * - Points which is not a leaf node, has dataLabels disabled by default. |
||
626 | * - Options set on series.levels is merged in. |
||
627 | * - Width of the dataLabel is set to match the width of the point shape. |
||
628 | */ |
||
629 | drawDataLabels: function() { |
||
630 | var series = this, |
||
631 | points = grep(series.points, function(n) { |
||
632 | return n.node.visible; |
||
633 | }), |
||
634 | options, |
||
635 | level; |
||
636 | each(points, function(point) { |
||
637 | level = series.levelMap[point.node.levelDynamic]; |
||
638 | // Set options to new object to avoid problems with scope |
||
639 | options = { |
||
640 | style: {} |
||
641 | }; |
||
642 | |||
643 | // If not a leaf, then label should be disabled as default |
||
644 | if (!point.node.isLeaf) { |
||
645 | options.enabled = false; |
||
646 | } |
||
647 | |||
648 | // If options for level exists, include them as well |
||
649 | if (level && level.dataLabels) { |
||
650 | options = merge(options, level.dataLabels); |
||
651 | series._hasPointLabels = true; |
||
652 | } |
||
653 | |||
654 | // Set dataLabel width to the width of the point shape. |
||
655 | if (point.shapeArgs) { |
||
656 | options.style.width = point.shapeArgs.width; |
||
657 | if (point.dataLabel) { |
||
658 | point.dataLabel.css({ |
||
659 | width: point.shapeArgs.width + 'px' |
||
660 | }); |
||
661 | } |
||
662 | } |
||
663 | |||
664 | // Merge custom options with point options |
||
665 | point.dlOptions = merge(options, point.options.dataLabels); |
||
666 | }); |
||
667 | Series.prototype.drawDataLabels.call(this); |
||
668 | }, |
||
669 | |||
670 | /** |
||
671 | * Over the alignment method by setting z index |
||
672 | */ |
||
673 | alignDataLabel: function(point) { |
||
674 | seriesTypes.column.prototype.alignDataLabel.apply(this, arguments); |
||
675 | if (point.dataLabel) { |
||
676 | point.dataLabel.attr({ |
||
677 | zIndex: point.node.zIndex + 1 |
||
678 | }); |
||
679 | } |
||
680 | }, |
||
681 | |||
682 | |||
683 | |||
684 | /** |
||
685 | * Extending ColumnSeries drawPoints |
||
686 | */ |
||
687 | drawPoints: function() { |
||
688 | var series = this, |
||
689 | points = grep(series.points, function(n) { |
||
690 | return n.node.visible; |
||
691 | }); |
||
692 | |||
693 | each(points, function(point) { |
||
694 | var groupKey = 'levelGroup-' + point.node.levelDynamic; |
||
695 | if (!series[groupKey]) { |
||
696 | series[groupKey] = series.chart.renderer.g(groupKey) |
||
697 | .attr({ |
||
698 | zIndex: 1000 - point.node.levelDynamic // @todo Set the zIndex based upon the number of levels, instead of using 1000 |
||
699 | }) |
||
700 | .add(series.group); |
||
701 | } |
||
702 | point.group = series[groupKey]; |
||
703 | |||
704 | }); |
||
705 | // Call standard drawPoints |
||
706 | seriesTypes.column.prototype.drawPoints.call(this); |
||
707 | |||
708 | // If drillToNode is allowed, set a point cursor on clickables & add drillId to point |
||
709 | if (series.options.allowDrillToNode) { |
||
710 | each(points, function(point) { |
||
711 | if (point.graphic) { |
||
712 | point.drillId = series.options.interactByLeaf ? series.drillToByLeaf(point) : series.drillToByGroup(point); |
||
713 | } |
||
714 | }); |
||
715 | } |
||
716 | }, |
||
717 | /** |
||
718 | * Add drilling on the suitable points |
||
719 | */ |
||
720 | onClickDrillToNode: function(event) { |
||
721 | var series = this, |
||
722 | point = event.point, |
||
723 | drillId = point && point.drillId; |
||
724 | // If a drill id is returned, add click event and cursor. |
||
725 | if (isString(drillId)) { |
||
726 | point.setState(''); // Remove hover |
||
727 | series.drillToNode(drillId); |
||
728 | } |
||
729 | }, |
||
730 | /** |
||
731 | * Finds the drill id for a parent node. |
||
732 | * Returns false if point should not have a click event |
||
733 | * @param {Object} point |
||
734 | * @return {string || boolean} Drill to id or false when point should not have a click event |
||
735 | */ |
||
736 | drillToByGroup: function(point) { |
||
737 | var series = this, |
||
738 | drillId = false; |
||
739 | if ((point.node.level - series.nodeMap[series.rootNode].level) === 1 && !point.node.isLeaf) { |
||
740 | drillId = point.id; |
||
741 | } |
||
742 | return drillId; |
||
743 | }, |
||
744 | /** |
||
745 | * Finds the drill id for a leaf node. |
||
746 | * Returns false if point should not have a click event |
||
747 | * @param {Object} point |
||
748 | * @return {string || boolean} Drill to id or false when point should not have a click event |
||
749 | */ |
||
750 | drillToByLeaf: function(point) { |
||
751 | var series = this, |
||
752 | drillId = false, |
||
753 | nodeParent; |
||
754 | if ((point.node.parent !== series.rootNode) && (point.node.isLeaf)) { |
||
755 | nodeParent = point.node; |
||
756 | while (!drillId) { |
||
757 | nodeParent = series.nodeMap[nodeParent.parent]; |
||
758 | if (nodeParent.parent === series.rootNode) { |
||
759 | drillId = nodeParent.id; |
||
760 | } |
||
761 | } |
||
762 | } |
||
763 | return drillId; |
||
764 | }, |
||
765 | drillUp: function() { |
||
766 | var series = this, |
||
767 | node = series.nodeMap[series.rootNode]; |
||
768 | if (node && isString(node.parent)) { |
||
769 | series.drillToNode(node.parent); |
||
770 | } |
||
771 | }, |
||
772 | drillToNode: function(id, redraw) { |
||
773 | var series = this, |
||
774 | nodeMap = series.nodeMap, |
||
775 | node = nodeMap[id]; |
||
776 | series.rootNode = id; |
||
777 | if (id === '') { |
||
778 | series.drillUpButton = series.drillUpButton.destroy(); |
||
779 | } else { |
||
780 | series.showDrillUpButton((node && node.name || id)); |
||
781 | } |
||
782 | this.isDirty = true; // Force redraw |
||
783 | if (pick(redraw, true)) { |
||
784 | this.chart.redraw(); |
||
785 | } |
||
786 | }, |
||
787 | showDrillUpButton: function(name) { |
||
788 | var series = this, |
||
789 | backText = (name || '< Back'),> |
||
790 | < Back'), buttonOptions = series.options.drillUpButton,> |
||
791 | < Back'), attr,> |
||
792 | < Back'), states;> |
||
793 | |||
794 | < Back'), if (buttonOptions.text) {> |
||
795 | < Back'), backText = buttonOptions.text;> |
||
796 | < Back'), }> |
||
797 | < Back'), if (!this.drillUpButton) {> |
||
798 | < Back'), attr = buttonOptions.theme;> |
||
799 | < Back'), states = attr && attr.states;> |
||
800 | |||
801 | < Back'), this.drillUpButton = this.chart.renderer.button(> |
||
802 | < Back'), backText,> |
||
803 | < Back'), null,> |
||
804 | < Back'), null,> |
||
805 | < Back'), function() {> |
||
806 | < Back'), series.drillUp();> |
||
807 | < Back'), },> |
||
808 | < Back'), attr,> |
||
809 | < Back'), states && states.hover,> |
||
810 | < Back'), states && states.select> |
||
811 | < Back'), )> |
||
812 | < Back'), .attr({> |
||
813 | < Back'), align: buttonOptions.position.align,> |
||
814 | < Back'), zIndex: 7> |
||
815 | < Back'), })> |
||
816 | < Back'), .add()> |
||
817 | < Back'), .align(buttonOptions.position, false, buttonOptions.relativeTo || 'plotBox');> |
||
818 | < Back'), } else {> |
||
819 | < Back'), this.drillUpButton.attr({> |
||
820 | < Back'), text: backText> |
||
821 | < Back'), })> |
||
822 | < Back'), .align();> |
||
823 | < Back'), }> |
||
824 | < Back'), },> |
||
825 | < Back'), buildKDTree: noop,> |
||
826 | < Back'), drawLegendSymbol: H.LegendSymbolMixin.drawRectangle,> |
||
827 | < Back'), getExtremes: function() {> |
||
828 | < Back'), // Get the extremes from the value data> |
||
829 | < Back'), Series.prototype.getExtremes.call(this, this.colorValueData);> |
||
830 | < Back'), this.valueMin = this.dataMin;> |
||
831 | < Back'), this.valueMax = this.dataMax;> |
||
832 | |||
833 | < Back'), // Get the extremes from the y data> |
||
834 | < Back'), Series.prototype.getExtremes.call(this);> |
||
835 | < Back'), },> |
||
836 | < Back'), getExtremesFromAll: true,> |
||
837 | < Back'), bindAxes: function() {> |
||
838 | < Back'), var treeAxis = {> |
||
839 | < Back'), endOnTick: false,> |
||
840 | < Back'), gridLineWidth: 0,> |
||
841 | < Back'), lineWidth: 0,> |
||
842 | < Back'), min: 0,> |
||
843 | < Back'), dataMin: 0,> |
||
844 | < Back'), minPadding: 0,> |
||
845 | < Back'), max: 100,> |
||
846 | < Back'), dataMax: 100,> |
||
847 | < Back'), maxPadding: 0,> |
||
848 | < Back'), startOnTick: false,> |
||
849 | < Back'), title: null,> |
||
850 | < Back'), tickPositions: []> |
||
851 | < Back'), };> |
||
852 | < Back'), Series.prototype.bindAxes.call(this);> |
||
853 | < Back'), H.extend(this.yAxis.options, treeAxis);> |
||
854 | < Back'), H.extend(this.xAxis.options, treeAxis);> |
||
855 | < Back'), }> |
||
856 | |||
857 | < Back'), // Point class> |
||
858 | < Back'), }, {> |
||
859 | < Back'), getClassName: function() {> |
||
860 | < Back'), var className = H.Point.prototype.getClassName.call(this),> |
||
861 | < Back'), series = this.series,> |
||
862 | < Back'), options = series.options;> |
||
863 | |||
864 | < Back'), // Above the current level> |
||
865 | < Back'), if (this.node.level <= series.nodeMap[series.rootNode].level) {=>> |
||
866 | < Back'),<= series.nodeMap[series.rootNode].level) { className += ' highcharts-above-level';=>> |
||
867 | |||
868 | < Back'),<= series.nodeMap[series.rootNode].level) { } else if (!this.node.isLeaf && !pick(options.interactByLeaf, !options.allowDrillToNode)) {=>> |
||
869 | < Back'),<= series.nodeMap[series.rootNode].level) { className += ' highcharts-internal-node-interactive';=>> |
||
870 | |||
871 | < Back'),<= series.nodeMap[series.rootNode].level) { } else if (!this.node.isLeaf) {=>> |
||
872 | < Back'),<= series.nodeMap[series.rootNode].level) { className += ' highcharts-internal-node';=>> |
||
873 | < Back'),<= series.nodeMap[series.rootNode].level) { }=>> |
||
874 | < Back'),<= series.nodeMap[series.rootNode].level) { return className;=>> |
||
875 | < Back'),<= series.nodeMap[series.rootNode].level) { },=>> |
||
876 | < Back'),<= series.nodeMap[series.rootNode].level) { isValid: function() {=>> |
||
877 | < Back'),<= series.nodeMap[series.rootNode].level) { return isNumber(this.value);=>> |
||
878 | < Back'),<= series.nodeMap[series.rootNode].level) { },=>> |
||
879 | < Back'),<= series.nodeMap[series.rootNode].level) { setState: function(state) {=>> |
||
880 | < Back'),<= series.nodeMap[series.rootNode].level) { H.Point.prototype.setState.call(this, state);=>> |
||
881 | |||
882 | < Back'),<= series.nodeMap[series.rootNode].level) { // Graphic does not exist when point is not visible.=>> |
||
883 | < Back'),<= series.nodeMap[series.rootNode].level) { if (this.graphic) {=>> |
||
884 | < Back'),<= series.nodeMap[series.rootNode].level) { this.graphic.attr({=>> |
||
885 | < Back'),<= series.nodeMap[series.rootNode].level) { zIndex: state === 'hover' ? 1 : 0=>> |
||
886 | < Back'),<= series.nodeMap[series.rootNode].level) { });=>> |
||
887 | < Back'),<= series.nodeMap[series.rootNode].level) { }=>> |
||
888 | < Back'),<= series.nodeMap[series.rootNode].level) { },=>> |
||
889 | < Back'),<= series.nodeMap[series.rootNode].level) { setVisible: seriesTypes.pie.prototype.pointClass.prototype.setVisible=>> |
||
890 | < Back'),<= series.nodeMap[series.rootNode].level) { });=>> |
||
891 | |||
892 | < Back'),<= series.nodeMap[series.rootNode].level) { }(Highcharts));=>> |
||
893 | < Back'),<= series.nodeMap[series.rootNode].level) {}));=>> |