highcharts_rails 0.1.0

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