corrade-nucleus-nucleons – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | /** |
2 | * @license Highcharts JS v5.0.10 (2017-03-31) |
||
3 | * Highcharts Drilldown module |
||
4 | * |
||
5 | * Author: Torstein Honsi |
||
6 | * License: www.highcharts.com/license |
||
7 | * |
||
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 | * Highcharts Drilldown module |
||
20 | * |
||
21 | * Author: Torstein Honsi |
||
22 | * License: www.highcharts.com/license |
||
23 | * |
||
24 | */ |
||
25 | |||
26 | |||
27 | var noop = H.noop, |
||
28 | color = H.color, |
||
29 | defaultOptions = H.defaultOptions, |
||
30 | each = H.each, |
||
31 | extend = H.extend, |
||
32 | format = H.format, |
||
33 | pick = H.pick, |
||
34 | wrap = H.wrap, |
||
35 | Chart = H.Chart, |
||
36 | seriesTypes = H.seriesTypes, |
||
37 | PieSeries = seriesTypes.pie, |
||
38 | ColumnSeries = seriesTypes.column, |
||
39 | Tick = H.Tick, |
||
40 | fireEvent = H.fireEvent, |
||
41 | inArray = H.inArray, |
||
42 | ddSeriesId = 1; |
||
43 | |||
44 | // Utilities |
||
45 | /* |
||
46 | * Return an intermediate color between two colors, according to pos where 0 |
||
47 | * is the from color and 1 is the to color. This method is copied from ColorAxis.js |
||
48 | * and should always be kept updated, until we get AMD support. |
||
49 | */ |
||
50 | function tweenColors(from, to, pos) { |
||
51 | // Check for has alpha, because rgba colors perform worse due to lack of |
||
52 | // support in WebKit. |
||
53 | var hasAlpha, |
||
54 | ret; |
||
55 | |||
56 | // Unsupported color, return to-color (#3920) |
||
57 | if (!to.rgba.length || !from.rgba.length) { |
||
58 | ret = to.input || 'none'; |
||
59 | |||
60 | // Interpolate |
||
61 | } else { |
||
62 | from = from.rgba; |
||
63 | to = to.rgba; |
||
64 | hasAlpha = (to[3] !== 1 || from[3] !== 1); |
||
65 | ret = (hasAlpha ? 'rgba(' : 'rgb(') + |
||
66 | Math.round(to[0] + (from[0] - to[0]) * (1 - pos)) + ',' + |
||
67 | Math.round(to[1] + (from[1] - to[1]) * (1 - pos)) + ',' + |
||
68 | Math.round(to[2] + (from[2] - to[2]) * (1 - pos)) + |
||
69 | (hasAlpha ? (',' + (to[3] + (from[3] - to[3]) * (1 - pos))) : '') + ')'; |
||
70 | } |
||
71 | return ret; |
||
72 | } |
||
73 | /** |
||
74 | * Handle animation of the color attributes directly |
||
75 | */ |
||
76 | each(['fill', 'stroke'], function(prop) { |
||
77 | H.Fx.prototype[prop + 'Setter'] = function() { |
||
78 | this.elem.attr( |
||
79 | prop, |
||
80 | tweenColors(color(this.start), color(this.end), this.pos), |
||
81 | null, |
||
82 | true |
||
83 | ); |
||
84 | }; |
||
85 | }); |
||
86 | |||
87 | // Add language |
||
88 | extend(defaultOptions.lang, { |
||
89 | drillUpText: '◁ Back to {series.name}' |
||
90 | }); |
||
91 | defaultOptions.drilldown = { |
||
92 | |||
93 | activeAxisLabelStyle: { |
||
94 | cursor: 'pointer', |
||
95 | color: '#003399', |
||
96 | fontWeight: 'bold', |
||
97 | textDecoration: 'underline' |
||
98 | }, |
||
99 | activeDataLabelStyle: { |
||
100 | cursor: 'pointer', |
||
101 | color: '#003399', |
||
102 | fontWeight: 'bold', |
||
103 | textDecoration: 'underline' |
||
104 | }, |
||
105 | |||
106 | animation: { |
||
107 | duration: 500 |
||
108 | }, |
||
109 | drillUpButton: { |
||
110 | position: { |
||
111 | align: 'right', |
||
112 | x: -10, |
||
113 | y: 10 |
||
114 | } |
||
115 | // relativeTo: 'plotBox' |
||
116 | // theme |
||
117 | } |
||
118 | }; |
||
119 | |||
120 | /** |
||
121 | * A general fadeIn method |
||
122 | */ |
||
123 | H.SVGRenderer.prototype.Element.prototype.fadeIn = function(animation) { |
||
124 | this |
||
125 | .attr({ |
||
126 | opacity: 0.1, |
||
127 | visibility: 'inherit' |
||
128 | }) |
||
129 | .animate({ |
||
130 | opacity: pick(this.newOpacity, 1) // newOpacity used in maps |
||
131 | }, animation || { |
||
132 | duration: 250 |
||
133 | }); |
||
134 | }; |
||
135 | |||
136 | Chart.prototype.addSeriesAsDrilldown = function(point, ddOptions) { |
||
137 | this.addSingleSeriesAsDrilldown(point, ddOptions); |
||
138 | this.applyDrilldown(); |
||
139 | }; |
||
140 | Chart.prototype.addSingleSeriesAsDrilldown = function(point, ddOptions) { |
||
141 | var oldSeries = point.series, |
||
142 | xAxis = oldSeries.xAxis, |
||
143 | yAxis = oldSeries.yAxis, |
||
144 | newSeries, |
||
145 | pointIndex, |
||
146 | levelSeries = [], |
||
147 | levelSeriesOptions = [], |
||
148 | level, |
||
149 | levelNumber, |
||
150 | last, |
||
151 | colorProp; |
||
152 | |||
153 | |||
154 | |||
155 | colorProp = { |
||
156 | color: point.color || oldSeries.color |
||
157 | }; |
||
158 | |||
159 | |||
160 | if (!this.drilldownLevels) { |
||
161 | this.drilldownLevels = []; |
||
162 | } |
||
163 | |||
164 | levelNumber = oldSeries.options._levelNumber || 0; |
||
165 | |||
166 | // See if we can reuse the registered series from last run |
||
167 | last = this.drilldownLevels[this.drilldownLevels.length - 1]; |
||
168 | if (last && last.levelNumber !== levelNumber) { |
||
169 | last = undefined; |
||
170 | } |
||
171 | |||
172 | ddOptions = extend(extend({ |
||
173 | _ddSeriesId: ddSeriesId++ |
||
174 | }, colorProp), ddOptions); |
||
175 | pointIndex = inArray(point, oldSeries.points); |
||
176 | |||
177 | // Record options for all current series |
||
178 | each(oldSeries.chart.series, function(series) { |
||
179 | if (series.xAxis === xAxis && !series.isDrilling) { |
||
180 | series.options._ddSeriesId = series.options._ddSeriesId || ddSeriesId++; |
||
181 | series.options._colorIndex = series.userOptions._colorIndex; |
||
182 | series.options._levelNumber = series.options._levelNumber || levelNumber; // #3182 |
||
183 | |||
184 | if (last) { |
||
185 | levelSeries = last.levelSeries; |
||
186 | levelSeriesOptions = last.levelSeriesOptions; |
||
187 | } else { |
||
188 | levelSeries.push(series); |
||
189 | levelSeriesOptions.push(series.options); |
||
190 | } |
||
191 | } |
||
192 | }); |
||
193 | |||
194 | // Add a record of properties for each drilldown level |
||
195 | level = extend({ |
||
196 | levelNumber: levelNumber, |
||
197 | seriesOptions: oldSeries.options, |
||
198 | levelSeriesOptions: levelSeriesOptions, |
||
199 | levelSeries: levelSeries, |
||
200 | shapeArgs: point.shapeArgs, |
||
201 | bBox: point.graphic ? point.graphic.getBBox() : {}, // no graphic in line series with markers disabled |
||
202 | color: point.isNull ? new H.Color(color).setOpacity(0).get() : color, |
||
203 | lowerSeriesOptions: ddOptions, |
||
204 | pointOptions: oldSeries.options.data[pointIndex], |
||
205 | pointIndex: pointIndex, |
||
206 | oldExtremes: { |
||
207 | xMin: xAxis && xAxis.userMin, |
||
208 | xMax: xAxis && xAxis.userMax, |
||
209 | yMin: yAxis && yAxis.userMin, |
||
210 | yMax: yAxis && yAxis.userMax |
||
211 | } |
||
212 | }, colorProp); |
||
213 | |||
214 | // Push it to the lookup array |
||
215 | this.drilldownLevels.push(level); |
||
216 | |||
217 | newSeries = level.lowerSeries = this.addSeries(ddOptions, false); |
||
218 | newSeries.options._levelNumber = levelNumber + 1; |
||
219 | if (xAxis) { |
||
220 | xAxis.oldPos = xAxis.pos; |
||
221 | xAxis.userMin = xAxis.userMax = null; |
||
222 | yAxis.userMin = yAxis.userMax = null; |
||
223 | } |
||
224 | |||
225 | // Run fancy cross-animation on supported and equal types |
||
226 | if (oldSeries.type === newSeries.type) { |
||
227 | newSeries.animate = newSeries.animateDrilldown || noop; |
||
228 | newSeries.options.animation = true; |
||
229 | } |
||
230 | }; |
||
231 | |||
232 | Chart.prototype.applyDrilldown = function() { |
||
233 | var drilldownLevels = this.drilldownLevels, |
||
234 | levelToRemove; |
||
235 | |||
236 | if (drilldownLevels && drilldownLevels.length > 0) { // #3352, async loading |
||
237 | levelToRemove = drilldownLevels[drilldownLevels.length - 1].levelNumber; |
||
238 | each(this.drilldownLevels, function(level) { |
||
239 | if (level.levelNumber === levelToRemove) { |
||
240 | each(level.levelSeries, function(series) { |
||
241 | if (series.options && series.options._levelNumber === levelToRemove) { // Not removed, not added as part of a multi-series drilldown |
||
242 | series.remove(false); |
||
243 | } |
||
244 | }); |
||
245 | } |
||
246 | }); |
||
247 | } |
||
248 | |||
249 | this.redraw(); |
||
250 | this.showDrillUpButton(); |
||
251 | }; |
||
252 | |||
253 | Chart.prototype.getDrilldownBackText = function() { |
||
254 | var drilldownLevels = this.drilldownLevels, |
||
255 | lastLevel; |
||
256 | if (drilldownLevels && drilldownLevels.length > 0) { // #3352, async loading |
||
257 | lastLevel = drilldownLevels[drilldownLevels.length - 1]; |
||
258 | lastLevel.series = lastLevel.seriesOptions; |
||
259 | return format(this.options.lang.drillUpText, lastLevel); |
||
260 | } |
||
261 | |||
262 | }; |
||
263 | |||
264 | Chart.prototype.showDrillUpButton = function() { |
||
265 | var chart = this, |
||
266 | backText = this.getDrilldownBackText(), |
||
267 | buttonOptions = chart.options.drilldown.drillUpButton, |
||
268 | attr, |
||
269 | states; |
||
270 | |||
271 | |||
272 | if (!this.drillUpButton) { |
||
273 | attr = buttonOptions.theme; |
||
274 | states = attr && attr.states; |
||
275 | |||
276 | this.drillUpButton = this.renderer.button( |
||
277 | backText, |
||
278 | null, |
||
279 | null, |
||
280 | function() { |
||
281 | chart.drillUp(); |
||
282 | }, |
||
283 | attr, |
||
284 | states && states.hover, |
||
285 | states && states.select |
||
286 | ) |
||
287 | .addClass('highcharts-drillup-button') |
||
288 | .attr({ |
||
289 | align: buttonOptions.position.align, |
||
290 | zIndex: 7 |
||
291 | }) |
||
292 | .add() |
||
293 | .align(buttonOptions.position, false, buttonOptions.relativeTo || 'plotBox'); |
||
294 | } else { |
||
295 | this.drillUpButton.attr({ |
||
296 | text: backText |
||
297 | }) |
||
298 | .align(); |
||
299 | } |
||
300 | }; |
||
301 | |||
302 | Chart.prototype.drillUp = function() { |
||
303 | var chart = this, |
||
304 | drilldownLevels = chart.drilldownLevels, |
||
305 | levelNumber = drilldownLevels[drilldownLevels.length - 1].levelNumber, |
||
306 | i = drilldownLevels.length, |
||
307 | chartSeries = chart.series, |
||
308 | seriesI, |
||
309 | level, |
||
310 | oldSeries, |
||
311 | newSeries, |
||
312 | oldExtremes, |
||
313 | addSeries = function(seriesOptions) { |
||
314 | var addedSeries; |
||
315 | each(chartSeries, function(series) { |
||
316 | if (series.options._ddSeriesId === seriesOptions._ddSeriesId) { |
||
317 | addedSeries = series; |
||
318 | } |
||
319 | }); |
||
320 | |||
321 | addedSeries = addedSeries || chart.addSeries(seriesOptions, false); |
||
322 | if (addedSeries.type === oldSeries.type && addedSeries.animateDrillupTo) { |
||
323 | addedSeries.animate = addedSeries.animateDrillupTo; |
||
324 | } |
||
325 | if (seriesOptions === level.seriesOptions) { |
||
326 | newSeries = addedSeries; |
||
327 | } |
||
328 | }; |
||
329 | |||
330 | while (i--) { |
||
331 | |||
332 | level = drilldownLevels[i]; |
||
333 | if (level.levelNumber === levelNumber) { |
||
334 | drilldownLevels.pop(); |
||
335 | |||
336 | // Get the lower series by reference or id |
||
337 | oldSeries = level.lowerSeries; |
||
338 | if (!oldSeries.chart) { // #2786 |
||
339 | seriesI = chartSeries.length; // #2919 |
||
340 | while (seriesI--) { |
||
341 | if (chartSeries[seriesI].options.id === level.lowerSeriesOptions.id && |
||
342 | chartSeries[seriesI].options._levelNumber === levelNumber + 1) { // #3867 |
||
343 | oldSeries = chartSeries[seriesI]; |
||
344 | break; |
||
345 | } |
||
346 | } |
||
347 | } |
||
348 | oldSeries.xData = []; // Overcome problems with minRange (#2898) |
||
349 | |||
350 | each(level.levelSeriesOptions, addSeries); |
||
351 | |||
352 | fireEvent(chart, 'drillup', { |
||
353 | seriesOptions: level.seriesOptions |
||
354 | }); |
||
355 | |||
356 | if (newSeries.type === oldSeries.type) { |
||
357 | newSeries.drilldownLevel = level; |
||
358 | newSeries.options.animation = chart.options.drilldown.animation; |
||
359 | |||
360 | if (oldSeries.animateDrillupFrom && oldSeries.chart) { // #2919 |
||
361 | oldSeries.animateDrillupFrom(level); |
||
362 | } |
||
363 | } |
||
364 | newSeries.options._levelNumber = levelNumber; |
||
365 | |||
366 | oldSeries.remove(false); |
||
367 | |||
368 | // Reset the zoom level of the upper series |
||
369 | if (newSeries.xAxis) { |
||
370 | oldExtremes = level.oldExtremes; |
||
371 | newSeries.xAxis.setExtremes(oldExtremes.xMin, oldExtremes.xMax, false); |
||
372 | newSeries.yAxis.setExtremes(oldExtremes.yMin, oldExtremes.yMax, false); |
||
373 | } |
||
374 | } |
||
375 | } |
||
376 | |||
377 | // Fire a once-off event after all series have been drilled up (#5158) |
||
378 | fireEvent(chart, 'drillupall'); |
||
379 | |||
380 | this.redraw(); |
||
381 | |||
382 | if (this.drilldownLevels.length === 0) { |
||
383 | this.drillUpButton = this.drillUpButton.destroy(); |
||
384 | } else { |
||
385 | this.drillUpButton.attr({ |
||
386 | text: this.getDrilldownBackText() |
||
387 | }) |
||
388 | .align(); |
||
389 | } |
||
390 | |||
391 | this.ddDupes.length = []; // #3315 |
||
392 | }; |
||
393 | |||
394 | |||
395 | ColumnSeries.prototype.supportsDrilldown = true; |
||
396 | |||
397 | /** |
||
398 | * When drilling up, keep the upper series invisible until the lower series has |
||
399 | * moved into place |
||
400 | */ |
||
401 | ColumnSeries.prototype.animateDrillupTo = function(init) { |
||
402 | if (!init) { |
||
403 | var newSeries = this, |
||
404 | level = newSeries.drilldownLevel; |
||
405 | |||
406 | // First hide all items before animating in again |
||
407 | each(this.points, function(point) { |
||
408 | var dataLabel = point.dataLabel; |
||
409 | |||
410 | if (point.graphic) { // #3407 |
||
411 | point.graphic.hide(); |
||
412 | } |
||
413 | |||
414 | if (dataLabel) { |
||
415 | // The data label is initially hidden, make sure it is not faded |
||
416 | // in (#6127) |
||
417 | dataLabel.hidden = dataLabel.attr('visibility') === 'hidden'; |
||
418 | |||
419 | if (!dataLabel.hidden) { |
||
420 | dataLabel.hide(); |
||
421 | if (point.connector) { |
||
422 | point.connector.hide(); |
||
423 | } |
||
424 | } |
||
425 | } |
||
426 | }); |
||
427 | |||
428 | |||
429 | // Do dummy animation on first point to get to complete |
||
430 | setTimeout(function() { |
||
431 | if (newSeries.points) { // May be destroyed in the meantime, #3389 |
||
432 | each(newSeries.points, function(point, i) { |
||
433 | // Fade in other points |
||
434 | var verb = |
||
435 | i === (level && level.pointIndex) ? 'show' : 'fadeIn', |
||
436 | inherit = verb === 'show' ? true : undefined, |
||
437 | dataLabel = point.dataLabel; |
||
438 | |||
439 | |||
440 | if (point.graphic) { // #3407 |
||
441 | point.graphic[verb](inherit); |
||
442 | } |
||
443 | |||
444 | if (dataLabel && !dataLabel.hidden) { // #6127 |
||
445 | dataLabel[verb](inherit); |
||
446 | if (point.connector) { |
||
447 | point.connector[verb](inherit); |
||
448 | } |
||
449 | } |
||
450 | }); |
||
451 | } |
||
452 | }, Math.max(this.chart.options.drilldown.animation.duration - 50, 0)); |
||
453 | |||
454 | // Reset |
||
455 | this.animate = noop; |
||
456 | } |
||
457 | |||
458 | }; |
||
459 | |||
460 | ColumnSeries.prototype.animateDrilldown = function(init) { |
||
461 | var series = this, |
||
462 | drilldownLevels = this.chart.drilldownLevels, |
||
463 | animateFrom, |
||
464 | animationOptions = this.chart.options.drilldown.animation, |
||
465 | xAxis = this.xAxis; |
||
466 | |||
467 | if (!init) { |
||
468 | each(drilldownLevels, function(level) { |
||
469 | if (series.options._ddSeriesId === level.lowerSeriesOptions._ddSeriesId) { |
||
470 | animateFrom = level.shapeArgs; |
||
471 | |||
472 | // Add the point colors to animate from |
||
473 | animateFrom.fill = level.color; |
||
474 | |||
475 | } |
||
476 | }); |
||
477 | |||
478 | animateFrom.x += (pick(xAxis.oldPos, xAxis.pos) - xAxis.pos); |
||
479 | |||
480 | each(this.points, function(point) { |
||
481 | var animateTo = point.shapeArgs; |
||
482 | |||
483 | |||
484 | // Add the point colors to animate to |
||
485 | animateTo.fill = point.color; |
||
486 | |||
487 | |||
488 | if (point.graphic) { |
||
489 | point.graphic |
||
490 | .attr(animateFrom) |
||
491 | .animate( |
||
492 | extend(point.shapeArgs, { |
||
493 | fill: point.color || series.color |
||
494 | }), |
||
495 | animationOptions |
||
496 | ); |
||
497 | } |
||
498 | if (point.dataLabel) { |
||
499 | point.dataLabel.fadeIn(animationOptions); |
||
500 | } |
||
501 | }); |
||
502 | this.animate = null; |
||
503 | } |
||
504 | |||
505 | }; |
||
506 | |||
507 | /** |
||
508 | * When drilling up, pull out the individual point graphics from the lower series |
||
509 | * and animate them into the origin point in the upper series. |
||
510 | */ |
||
511 | ColumnSeries.prototype.animateDrillupFrom = function(level) { |
||
512 | var animationOptions = this.chart.options.drilldown.animation, |
||
513 | group = this.group, |
||
514 | series = this; |
||
515 | |||
516 | // Cancel mouse events on the series group (#2787) |
||
517 | each(series.trackerGroups, function(key) { |
||
518 | if (series[key]) { // we don't always have dataLabelsGroup |
||
519 | series[key].on('mouseover'); |
||
520 | } |
||
521 | }); |
||
522 | |||
523 | |||
524 | delete this.group; |
||
525 | each(this.points, function(point) { |
||
526 | var graphic = point.graphic, |
||
527 | animateTo = level.shapeArgs, |
||
528 | complete = function() { |
||
529 | graphic.destroy(); |
||
530 | if (group) { |
||
531 | group = group.destroy(); |
||
532 | } |
||
533 | }; |
||
534 | |||
535 | if (graphic) { |
||
536 | |||
537 | delete point.graphic; |
||
538 | |||
539 | |||
540 | animateTo.fill = level.color; |
||
541 | |||
542 | |||
543 | if (animationOptions) { |
||
544 | graphic.animate( |
||
545 | animateTo, |
||
546 | H.merge(animationOptions, { |
||
547 | complete: complete |
||
548 | }) |
||
549 | ); |
||
550 | } else { |
||
551 | graphic.attr(animateTo); |
||
552 | complete(); |
||
553 | } |
||
554 | } |
||
555 | }); |
||
556 | }; |
||
557 | |||
558 | if (PieSeries) { |
||
559 | extend(PieSeries.prototype, { |
||
560 | supportsDrilldown: true, |
||
561 | animateDrillupTo: ColumnSeries.prototype.animateDrillupTo, |
||
562 | animateDrillupFrom: ColumnSeries.prototype.animateDrillupFrom, |
||
563 | |||
564 | animateDrilldown: function(init) { |
||
565 | var level = this.chart.drilldownLevels[this.chart.drilldownLevels.length - 1], |
||
566 | animationOptions = this.chart.options.drilldown.animation, |
||
567 | animateFrom = level.shapeArgs, |
||
568 | start = animateFrom.start, |
||
569 | angle = animateFrom.end - start, |
||
570 | startAngle = angle / this.points.length; |
||
571 | |||
572 | if (!init) { |
||
573 | each(this.points, function(point, i) { |
||
574 | var animateTo = point.shapeArgs; |
||
575 | |||
576 | |||
577 | animateFrom.fill = level.color; |
||
578 | animateTo.fill = point.color; |
||
579 | |||
580 | |||
581 | if (point.graphic) { |
||
582 | point.graphic |
||
583 | .attr(H.merge(animateFrom, { |
||
584 | start: start + i * startAngle, |
||
585 | end: start + (i + 1) * startAngle |
||
586 | }))[animationOptions ? 'animate' : 'attr']( |
||
587 | animateTo, |
||
588 | animationOptions |
||
589 | ); |
||
590 | } |
||
591 | }); |
||
592 | this.animate = null; |
||
593 | } |
||
594 | } |
||
595 | }); |
||
596 | } |
||
597 | |||
598 | H.Point.prototype.doDrilldown = function(_holdRedraw, category, originalEvent) { |
||
599 | var series = this.series, |
||
600 | chart = series.chart, |
||
601 | drilldown = chart.options.drilldown, |
||
602 | i = (drilldown.series || []).length, |
||
603 | seriesOptions; |
||
604 | |||
605 | if (!chart.ddDupes) { |
||
606 | chart.ddDupes = []; |
||
607 | } |
||
608 | |||
609 | while (i-- && !seriesOptions) { |
||
610 | if (drilldown.series[i].id === this.drilldown && inArray(this.drilldown, chart.ddDupes) === -1) { |
||
611 | seriesOptions = drilldown.series[i]; |
||
612 | chart.ddDupes.push(this.drilldown); |
||
613 | } |
||
614 | } |
||
615 | |||
616 | // Fire the event. If seriesOptions is undefined, the implementer can check for |
||
617 | // seriesOptions, and call addSeriesAsDrilldown async if necessary. |
||
618 | fireEvent(chart, 'drilldown', { |
||
619 | point: this, |
||
620 | seriesOptions: seriesOptions, |
||
621 | category: category, |
||
622 | originalEvent: originalEvent, |
||
623 | points: category !== undefined && this.series.xAxis.getDDPoints(category).slice(0) |
||
624 | }, function(e) { |
||
625 | var chart = e.point.series && e.point.series.chart, |
||
626 | seriesOptions = e.seriesOptions; |
||
627 | if (chart && seriesOptions) { |
||
628 | if (_holdRedraw) { |
||
629 | chart.addSingleSeriesAsDrilldown(e.point, seriesOptions); |
||
630 | } else { |
||
631 | chart.addSeriesAsDrilldown(e.point, seriesOptions); |
||
632 | } |
||
633 | } |
||
634 | }); |
||
635 | |||
636 | |||
637 | }; |
||
638 | |||
639 | /** |
||
640 | * Drill down to a given category. This is the same as clicking on an axis label. |
||
641 | */ |
||
642 | H.Axis.prototype.drilldownCategory = function(x, e) { |
||
643 | var key, |
||
644 | point, |
||
645 | ddPointsX = this.getDDPoints(x); |
||
646 | for (key in ddPointsX) { |
||
647 | point = ddPointsX[key]; |
||
648 | if (point && point.series && point.series.visible && point.doDrilldown) { // #3197 |
||
649 | point.doDrilldown(true, x, e); |
||
650 | } |
||
651 | } |
||
652 | this.chart.applyDrilldown(); |
||
653 | }; |
||
654 | |||
655 | /** |
||
656 | * Return drillable points for this specific X value |
||
657 | */ |
||
658 | H.Axis.prototype.getDDPoints = function(x) { |
||
659 | var ret = []; |
||
660 | each(this.series, function(series) { |
||
661 | var i, |
||
662 | xData = series.xData, |
||
663 | points = series.points; |
||
664 | |||
665 | for (i = 0; i < xData.length; i++) {> |
||
666 | < xData.length; i++) { if (xData[i] === x && series.options.data[i] && series.options.data[i].drilldown) {> |
||
667 | < xData.length; i++) { ret.push(points ? points[i] : true);> |
||
668 | < xData.length; i++) { break;> |
||
669 | < xData.length; i++) { }> |
||
670 | < xData.length; i++) { }> |
||
671 | < xData.length; i++) { });> |
||
672 | < xData.length; i++) { return ret;> |
||
673 | < xData.length; i++) { };> |
||
674 | |||
675 | |||
676 | < xData.length; i++) { /**> |
||
677 | < xData.length; i++) { * Make a tick label drillable, or remove drilling on update> |
||
678 | < xData.length; i++) { */> |
||
679 | < xData.length; i++) { Tick.prototype.drillable = function() {> |
||
680 | < xData.length; i++) { var pos = this.pos,> |
||
681 | < xData.length; i++) { label = this.label,> |
||
682 | < xData.length; i++) { axis = this.axis,> |
||
683 | < xData.length; i++) { isDrillable = axis.coll === 'xAxis' && axis.getDDPoints,> |
||
684 | < xData.length; i++) { ddPointsX = isDrillable && axis.getDDPoints(pos);> |
||
685 | |||
686 | < xData.length; i++) { if (isDrillable) {> |
||
687 | < xData.length; i++) { if (label && ddPointsX.length) {> |
||
688 | < xData.length; i++) { label.drillable = true;> |
||
689 | |||
690 | |||
691 | < xData.length; i++) { if (!label.basicStyles) {> |
||
692 | < xData.length; i++) { label.basicStyles = H.merge(label.styles);> |
||
693 | < xData.length; i++) { }> |
||
694 | |||
695 | |||
696 | < xData.length; i++) { label> |
||
697 | < xData.length; i++) { .addClass('highcharts-drilldown-axis-label')> |
||
698 | |||
699 | < xData.length; i++) { .css(axis.chart.options.drilldown.activeAxisLabelStyle)> |
||
700 | |||
701 | < xData.length; i++) { .on('click', function(e) {> |
||
702 | < xData.length; i++) { axis.drilldownCategory(pos, e);> |
||
703 | < xData.length; i++) { });> |
||
704 | |||
705 | < xData.length; i++) { } else if (label && label.drillable) {> |
||
706 | |||
707 | |||
708 | < xData.length; i++) { label.styles = {}; // reset for full overwrite of styles> |
||
709 | < xData.length; i++) { label.css(label.basicStyles);> |
||
710 | |||
711 | |||
712 | < xData.length; i++) { label.on('click', null); // #3806 > |
||
713 | < xData.length; i++) { label.removeClass('highcharts-drilldown-axis-label');> |
||
714 | < xData.length; i++) { }> |
||
715 | < xData.length; i++) { }> |
||
716 | < xData.length; i++) { };> |
||
717 | |||
718 | < xData.length; i++) { /**> |
||
719 | < xData.length; i++) { * Always keep the drillability updated (#3951)> |
||
720 | < xData.length; i++) { */> |
||
721 | < xData.length; i++) { wrap(Tick.prototype, 'addLabel', function(proceed) {> |
||
722 | < xData.length; i++) { proceed.call(this);> |
||
723 | < xData.length; i++) { this.drillable();> |
||
724 | < xData.length; i++) { });> |
||
725 | |||
726 | |||
727 | < xData.length; i++) { /**> |
||
728 | < xData.length; i++) { * On initialization of each point, identify its label and make it clickable. Also, provide a> |
||
729 | < xData.length; i++) { * list of points associated to that label.> |
||
730 | < xData.length; i++) { */> |
||
731 | < xData.length; i++) { wrap(H.Point.prototype, 'init', function(proceed, series, options, x) {> |
||
732 | < xData.length; i++) { var point = proceed.call(this, series, options, x),> |
||
733 | < xData.length; i++) { xAxis = series.xAxis,> |
||
734 | < xData.length; i++) { tick = xAxis && xAxis.ticks[x];> |
||
735 | |||
736 | < xData.length; i++) { if (point.drilldown) {> |
||
737 | |||
738 | < xData.length; i++) { // Add the click event to the point > |
||
739 | < xData.length; i++) { H.addEvent(point, 'click', function(e) {> |
||
740 | < xData.length; i++) { if (series.xAxis && series.chart.options.drilldown.allowPointDrilldown === false) {> |
||
741 | < xData.length; i++) { series.xAxis.drilldownCategory(point.x, e); // #5822, x changed> |
||
742 | < xData.length; i++) { } else {> |
||
743 | < xData.length; i++) { point.doDrilldown(undefined, undefined, e);> |
||
744 | < xData.length; i++) { }> |
||
745 | < xData.length; i++) { });> |
||
746 | < xData.length; i++) { /*wrap(point, 'importEvents', function (proceed) { // wrapping importEvents makes point.click event work> |
||
747 | < xData.length; i++) { if (!this.hasImportedEvents) {> |
||
748 | < xData.length; i++) { proceed.call(this);> |
||
749 | < xData.length; i++) { H.addEvent(this, 'click', function () {> |
||
750 | < xData.length; i++) { this.doDrilldown();> |
||
751 | < xData.length; i++) { });> |
||
752 | < xData.length; i++) { }> |
||
753 | < xData.length; i++) { });*/> |
||
754 | |||
755 | < xData.length; i++) { }> |
||
756 | |||
757 | < xData.length; i++) { // Add or remove click handler and style on the tick label> |
||
758 | < xData.length; i++) { if (tick) {> |
||
759 | < xData.length; i++) { tick.drillable();> |
||
760 | < xData.length; i++) { }> |
||
761 | |||
762 | < xData.length; i++) { return point;> |
||
763 | < xData.length; i++) { });> |
||
764 | |||
765 | < xData.length; i++) { wrap(H.Series.prototype, 'drawDataLabels', function(proceed) {> |
||
766 | < xData.length; i++) { var css = this.chart.options.drilldown.activeDataLabelStyle,> |
||
767 | < xData.length; i++) { renderer = this.chart.renderer;> |
||
768 | |||
769 | < xData.length; i++) { proceed.call(this);> |
||
770 | |||
771 | < xData.length; i++) { each(this.points, function(point) {> |
||
772 | < xData.length; i++) { var pointCSS = {};> |
||
773 | < xData.length; i++) { if (point.drilldown && point.dataLabel) {> |
||
774 | < xData.length; i++) { if (css.color === 'contrast') {> |
||
775 | < xData.length; i++) { pointCSS.color = renderer.getContrast(point.color || this.color);> |
||
776 | < xData.length; i++) { }> |
||
777 | < xData.length; i++) { point.dataLabel> |
||
778 | < xData.length; i++) { .addClass('highcharts-drilldown-data-label');> |
||
779 | |||
780 | |||
781 | < xData.length; i++) { point.dataLabel> |
||
782 | < xData.length; i++) { .css(css)> |
||
783 | < xData.length; i++) { .css(pointCSS);> |
||
784 | |||
785 | < xData.length; i++) { }> |
||
786 | < xData.length; i++) { }, this);> |
||
787 | < xData.length; i++) { });> |
||
788 | |||
789 | < xData.length; i++) { // Mark the trackers with a pointer > |
||
790 | < xData.length; i++) { var type,> |
||
791 | < xData.length; i++) { drawTrackerWrapper = function(proceed) {> |
||
792 | < xData.length; i++) { proceed.call(this);> |
||
793 | < xData.length; i++) { each(this.points, function(point) {> |
||
794 | < xData.length; i++) { if (point.drilldown && point.graphic) {> |
||
795 | < xData.length; i++) { point.graphic.addClass('highcharts-drilldown-point');> |
||
796 | |||
797 | |||
798 | < xData.length; i++) { point.graphic.css({> |
||
799 | < xData.length; i++) { cursor: 'pointer'> |
||
800 | < xData.length; i++) { });> |
||
801 | |||
802 | < xData.length; i++) { }> |
||
803 | < xData.length; i++) { });> |
||
804 | < xData.length; i++) { };> |
||
805 | < xData.length; i++) { for (type in seriesTypes) {> |
||
806 | < xData.length; i++) { if (seriesTypes[type].prototype.supportsDrilldown) {> |
||
807 | < xData.length; i++) { wrap(seriesTypes[type].prototype, 'drawTracker', drawTrackerWrapper);> |
||
808 | < xData.length; i++) { }> |
||
809 | < xData.length; i++) { }> |
||
810 | |||
811 | < xData.length; i++) { }(Highcharts));> |
||
812 | < xData.length; i++) {}));> |