highcharts_rails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,810 @@
1
+ /**
2
+ * @license Highcharts JS v5.0.6 (2016-12-07)
3
+ *
4
+ * (c) 2009-2016 Torstein Honsi
5
+ *
6
+ * License: www.highcharts.com/license
7
+ */
8
+ (function(factory) {
9
+ if (typeof module === 'object' && module.exports) {
10
+ module.exports = factory;
11
+ } else {
12
+ factory(Highcharts);
13
+ }
14
+ }(function(Highcharts) {
15
+ (function(H) {
16
+ /**
17
+ * (c) 2010-2016 Torstein Honsi
18
+ *
19
+ * License: www.highcharts.com/license
20
+ */
21
+ 'use strict';
22
+ var Axis = H.Axis,
23
+ Chart = H.Chart,
24
+ color = H.color,
25
+ ColorAxis,
26
+ each = H.each,
27
+ extend = H.extend,
28
+ isNumber = H.isNumber,
29
+ Legend = H.Legend,
30
+ LegendSymbolMixin = H.LegendSymbolMixin,
31
+ noop = H.noop,
32
+ merge = H.merge,
33
+ pick = H.pick,
34
+ wrap = H.wrap;
35
+
36
+ /**
37
+ * The ColorAxis object for inclusion in gradient legends
38
+ */
39
+ ColorAxis = H.ColorAxis = function() {
40
+ this.init.apply(this, arguments);
41
+ };
42
+ extend(ColorAxis.prototype, Axis.prototype);
43
+ extend(ColorAxis.prototype, {
44
+ defaultColorAxisOptions: {
45
+ lineWidth: 0,
46
+ minPadding: 0,
47
+ maxPadding: 0,
48
+ gridLineWidth: 1,
49
+ tickPixelInterval: 72,
50
+ startOnTick: true,
51
+ endOnTick: true,
52
+ offset: 0,
53
+ marker: {
54
+ animation: {
55
+ duration: 50
56
+ },
57
+ width: 0.01,
58
+
59
+ color: '#999999'
60
+
61
+ },
62
+ labels: {
63
+ overflow: 'justify'
64
+ },
65
+ minColor: '#e6ebf5',
66
+ maxColor: '#003399',
67
+ tickLength: 5,
68
+ showInLegend: true
69
+ },
70
+
71
+ // Properties to preserve after destroy, for Axis.update (#5881)
72
+ keepProps: ['legendGroup', 'legendItem', 'legendSymbol']
73
+ .concat(Axis.prototype.keepProps),
74
+
75
+ /**
76
+ * Initialize the color axis
77
+ */
78
+ init: function(chart, userOptions) {
79
+ var horiz = chart.options.legend.layout !== 'vertical',
80
+ options;
81
+
82
+ this.coll = 'colorAxis';
83
+
84
+ // Build the options
85
+ options = merge(this.defaultColorAxisOptions, {
86
+ side: horiz ? 2 : 1,
87
+ reversed: !horiz
88
+ }, userOptions, {
89
+ opposite: !horiz,
90
+ showEmpty: false,
91
+ title: null
92
+ });
93
+
94
+ Axis.prototype.init.call(this, chart, options);
95
+
96
+ // Base init() pushes it to the xAxis array, now pop it again
97
+ //chart[this.isXAxis ? 'xAxis' : 'yAxis'].pop();
98
+
99
+ // Prepare data classes
100
+ if (userOptions.dataClasses) {
101
+ this.initDataClasses(userOptions);
102
+ }
103
+ this.initStops(userOptions);
104
+
105
+ // Override original axis properties
106
+ this.horiz = horiz;
107
+ this.zoomEnabled = false;
108
+
109
+ // Add default values
110
+ this.defaultLegendLength = 200;
111
+ },
112
+
113
+ /*
114
+ * Return an intermediate color between two colors, according to pos where 0
115
+ * is the from color and 1 is the to color.
116
+ * NOTE: Changes here should be copied
117
+ * to the same function in drilldown.src.js and solid-gauge-src.js.
118
+ */
119
+ tweenColors: function(from, to, pos) {
120
+ // Check for has alpha, because rgba colors perform worse due to lack of
121
+ // support in WebKit.
122
+ var hasAlpha,
123
+ ret;
124
+
125
+ // Unsupported color, return to-color (#3920)
126
+ if (!to.rgba.length || !from.rgba.length) {
127
+ ret = to.input || 'none';
128
+
129
+ // Interpolate
130
+ } else {
131
+ from = from.rgba;
132
+ to = to.rgba;
133
+ hasAlpha = (to[3] !== 1 || from[3] !== 1);
134
+ ret = (hasAlpha ? 'rgba(' : 'rgb(') +
135
+ Math.round(to[0] + (from[0] - to[0]) * (1 - pos)) + ',' +
136
+ Math.round(to[1] + (from[1] - to[1]) * (1 - pos)) + ',' +
137
+ Math.round(to[2] + (from[2] - to[2]) * (1 - pos)) +
138
+ (hasAlpha ? (',' + (to[3] + (from[3] - to[3]) * (1 - pos))) : '') + ')';
139
+ }
140
+ return ret;
141
+ },
142
+
143
+ initDataClasses: function(userOptions) {
144
+ var axis = this,
145
+ chart = this.chart,
146
+ dataClasses,
147
+ colorCounter = 0,
148
+ colorCount = chart.options.chart.colorCount,
149
+ options = this.options,
150
+ len = userOptions.dataClasses.length;
151
+ this.dataClasses = dataClasses = [];
152
+ this.legendItems = [];
153
+
154
+ each(userOptions.dataClasses, function(dataClass, i) {
155
+ var colors;
156
+
157
+ dataClass = merge(dataClass);
158
+ dataClasses.push(dataClass);
159
+ if (!dataClass.color) {
160
+ if (options.dataClassColor === 'category') {
161
+
162
+ colors = chart.options.colors;
163
+ colorCount = colors.length;
164
+ dataClass.color = colors[colorCounter];
165
+
166
+ dataClass.colorIndex = colorCounter;
167
+
168
+ // increase and loop back to zero
169
+ colorCounter++;
170
+ if (colorCounter === colorCount) {
171
+ colorCounter = 0;
172
+ }
173
+ } else {
174
+ dataClass.color = axis.tweenColors(
175
+ color(options.minColor),
176
+ color(options.maxColor),
177
+ len < 2 ? 0.5 : i / (len - 1) // #3219
178
+ );
179
+ }
180
+ }
181
+ });
182
+ },
183
+
184
+ initStops: function(userOptions) {
185
+ this.stops = userOptions.stops || [
186
+ [0, this.options.minColor],
187
+ [1, this.options.maxColor]
188
+ ];
189
+ each(this.stops, function(stop) {
190
+ stop.color = color(stop[1]);
191
+ });
192
+ },
193
+
194
+ /**
195
+ * Extend the setOptions method to process extreme colors and color
196
+ * stops.
197
+ */
198
+ setOptions: function(userOptions) {
199
+ Axis.prototype.setOptions.call(this, userOptions);
200
+
201
+ this.options.crosshair = this.options.marker;
202
+ },
203
+
204
+ setAxisSize: function() {
205
+ var symbol = this.legendSymbol,
206
+ chart = this.chart,
207
+ legendOptions = chart.options.legend || {},
208
+ x,
209
+ y,
210
+ width,
211
+ height;
212
+
213
+ if (symbol) {
214
+ this.left = x = symbol.attr('x');
215
+ this.top = y = symbol.attr('y');
216
+ this.width = width = symbol.attr('width');
217
+ this.height = height = symbol.attr('height');
218
+ this.right = chart.chartWidth - x - width;
219
+ this.bottom = chart.chartHeight - y - height;
220
+
221
+ this.len = this.horiz ? width : height;
222
+ this.pos = this.horiz ? x : y;
223
+ } else {
224
+ // Fake length for disabled legend to avoid tick issues and such (#5205)
225
+ this.len = (this.horiz ? legendOptions.symbolWidth : legendOptions.symbolHeight) || this.defaultLegendLength;
226
+ }
227
+ },
228
+
229
+ /**
230
+ * Translate from a value to a color
231
+ */
232
+ toColor: function(value, point) {
233
+ var pos,
234
+ stops = this.stops,
235
+ from,
236
+ to,
237
+ color,
238
+ dataClasses = this.dataClasses,
239
+ dataClass,
240
+ i;
241
+
242
+ if (dataClasses) {
243
+ i = dataClasses.length;
244
+ while (i--) {
245
+ dataClass = dataClasses[i];
246
+ from = dataClass.from;
247
+ to = dataClass.to;
248
+ if ((from === undefined || value >= from) && (to === undefined || value <= to)) {
249
+ color = dataClass.color;
250
+ if (point) {
251
+ point.dataClass = i;
252
+ point.colorIndex = dataClass.colorIndex;
253
+ }
254
+ break;
255
+ }
256
+ }
257
+
258
+ } else {
259
+
260
+ if (this.isLog) {
261
+ value = this.val2lin(value);
262
+ }
263
+ pos = 1 - ((this.max - value) / ((this.max - this.min) || 1));
264
+ i = stops.length;
265
+ while (i--) {
266
+ if (pos > stops[i][0]) {
267
+ break;
268
+ }
269
+ }
270
+ from = stops[i] || stops[i + 1];
271
+ to = stops[i + 1] || from;
272
+
273
+ // The position within the gradient
274
+ pos = 1 - (to[0] - pos) / ((to[0] - from[0]) || 1);
275
+
276
+ color = this.tweenColors(
277
+ from.color,
278
+ to.color,
279
+ pos
280
+ );
281
+ }
282
+ return color;
283
+ },
284
+
285
+ /**
286
+ * Override the getOffset method to add the whole axis groups inside the legend.
287
+ */
288
+ getOffset: function() {
289
+ var group = this.legendGroup,
290
+ sideOffset = this.chart.axisOffset[this.side];
291
+
292
+ if (group) {
293
+
294
+ // Hook for the getOffset method to add groups to this parent group
295
+ this.axisParent = group;
296
+
297
+ // Call the base
298
+ Axis.prototype.getOffset.call(this);
299
+
300
+ // First time only
301
+ if (!this.added) {
302
+
303
+ this.added = true;
304
+
305
+ this.labelLeft = 0;
306
+ this.labelRight = this.width;
307
+ }
308
+ // Reset it to avoid color axis reserving space
309
+ this.chart.axisOffset[this.side] = sideOffset;
310
+ }
311
+ },
312
+
313
+ /**
314
+ * Create the color gradient
315
+ */
316
+ setLegendColor: function() {
317
+ var grad,
318
+ horiz = this.horiz,
319
+ options = this.options,
320
+ reversed = this.reversed,
321
+ one = reversed ? 1 : 0,
322
+ zero = reversed ? 0 : 1;
323
+
324
+ grad = horiz ? [one, 0, zero, 0] : [0, zero, 0, one]; // #3190
325
+ this.legendColor = {
326
+ linearGradient: {
327
+ x1: grad[0],
328
+ y1: grad[1],
329
+ x2: grad[2],
330
+ y2: grad[3]
331
+ },
332
+ stops: options.stops || [
333
+ [0, options.minColor],
334
+ [1, options.maxColor]
335
+ ]
336
+ };
337
+ },
338
+
339
+ /**
340
+ * The color axis appears inside the legend and has its own legend symbol
341
+ */
342
+ drawLegendSymbol: function(legend, item) {
343
+ var padding = legend.padding,
344
+ legendOptions = legend.options,
345
+ horiz = this.horiz,
346
+ width = pick(legendOptions.symbolWidth, horiz ? this.defaultLegendLength : 12),
347
+ height = pick(legendOptions.symbolHeight, horiz ? 12 : this.defaultLegendLength),
348
+ labelPadding = pick(legendOptions.labelPadding, horiz ? 16 : 30),
349
+ itemDistance = pick(legendOptions.itemDistance, 10);
350
+
351
+ this.setLegendColor();
352
+
353
+ // Create the gradient
354
+ item.legendSymbol = this.chart.renderer.rect(
355
+ 0,
356
+ legend.baseline - 11,
357
+ width,
358
+ height
359
+ ).attr({
360
+ zIndex: 1
361
+ }).add(item.legendGroup);
362
+
363
+ // Set how much space this legend item takes up
364
+ this.legendItemWidth = width + padding + (horiz ? itemDistance : labelPadding);
365
+ this.legendItemHeight = height + padding + (horiz ? labelPadding : 0);
366
+ },
367
+ /**
368
+ * Fool the legend
369
+ */
370
+ setState: noop,
371
+ visible: true,
372
+ setVisible: noop,
373
+ getSeriesExtremes: function() {
374
+ var series;
375
+ if (this.series.length) {
376
+ series = this.series[0];
377
+ this.dataMin = series.valueMin;
378
+ this.dataMax = series.valueMax;
379
+ }
380
+ },
381
+ drawCrosshair: function(e, point) {
382
+ var plotX = point && point.plotX,
383
+ plotY = point && point.plotY,
384
+ crossPos,
385
+ axisPos = this.pos,
386
+ axisLen = this.len;
387
+
388
+ if (point) {
389
+ crossPos = this.toPixels(point[point.series.colorKey]);
390
+ if (crossPos < axisPos) {
391
+ crossPos = axisPos - 2;
392
+ } else if (crossPos > axisPos + axisLen) {
393
+ crossPos = axisPos + axisLen + 2;
394
+ }
395
+
396
+ point.plotX = crossPos;
397
+ point.plotY = this.len - crossPos;
398
+ Axis.prototype.drawCrosshair.call(this, e, point);
399
+ point.plotX = plotX;
400
+ point.plotY = plotY;
401
+
402
+ if (this.cross) {
403
+ this.cross
404
+ .addClass('highcharts-coloraxis-marker')
405
+ .add(this.legendGroup);
406
+
407
+
408
+ this.cross.attr({
409
+ fill: this.crosshair.color
410
+ });
411
+
412
+
413
+ }
414
+ }
415
+ },
416
+ getPlotLinePath: function(a, b, c, d, pos) {
417
+ return isNumber(pos) ? // crosshairs only // #3969 pos can be 0 !!
418
+ (this.horiz ? ['M', pos - 4, this.top - 6, 'L', pos + 4, this.top - 6, pos, this.top, 'Z'] : ['M', this.left, pos, 'L', this.left - 6, pos + 6, this.left - 6, pos - 6, 'Z']) :
419
+ Axis.prototype.getPlotLinePath.call(this, a, b, c, d);
420
+ },
421
+
422
+ update: function(newOptions, redraw) {
423
+ var chart = this.chart,
424
+ legend = chart.legend;
425
+
426
+ each(this.series, function(series) {
427
+ series.isDirtyData = true; // Needed for Axis.update when choropleth colors change
428
+ });
429
+
430
+ // When updating data classes, destroy old items and make sure new ones are created (#3207)
431
+ if (newOptions.dataClasses && legend.allItems) {
432
+ each(legend.allItems, function(item) {
433
+ if (item.isDataClass) {
434
+ item.legendGroup.destroy();
435
+ }
436
+ });
437
+ chart.isDirtyLegend = true;
438
+ }
439
+
440
+ // Keep the options structure updated for export. Unlike xAxis and yAxis, the colorAxis is
441
+ // not an array. (#3207)
442
+ chart.options[this.coll] = merge(this.userOptions, newOptions);
443
+
444
+ Axis.prototype.update.call(this, newOptions, redraw);
445
+ if (this.legendItem) {
446
+ this.setLegendColor();
447
+ legend.colorizeItem(this, true);
448
+ }
449
+ },
450
+
451
+ /**
452
+ * Get the legend item symbols for data classes
453
+ */
454
+ getDataClassLegendSymbols: function() {
455
+ var axis = this,
456
+ chart = this.chart,
457
+ legendItems = this.legendItems,
458
+ legendOptions = chart.options.legend,
459
+ valueDecimals = legendOptions.valueDecimals,
460
+ valueSuffix = legendOptions.valueSuffix || '',
461
+ name;
462
+
463
+ if (!legendItems.length) {
464
+ each(this.dataClasses, function(dataClass, i) {
465
+ var vis = true,
466
+ from = dataClass.from,
467
+ to = dataClass.to;
468
+
469
+ // Assemble the default name. This can be overridden by legend.options.labelFormatter
470
+ name = '';
471
+ if (from === undefined) {
472
+ name = '< ';
473
+ } else if (to === undefined) {
474
+ name = '> ';
475
+ }
476
+ if (from !== undefined) {
477
+ name += H.numberFormat(from, valueDecimals) + valueSuffix;
478
+ }
479
+ if (from !== undefined && to !== undefined) {
480
+ name += ' - ';
481
+ }
482
+ if (to !== undefined) {
483
+ name += H.numberFormat(to, valueDecimals) + valueSuffix;
484
+ }
485
+ // Add a mock object to the legend items
486
+ legendItems.push(extend({
487
+ chart: chart,
488
+ name: name,
489
+ options: {},
490
+ drawLegendSymbol: LegendSymbolMixin.drawRectangle,
491
+ visible: true,
492
+ setState: noop,
493
+ isDataClass: true,
494
+ setVisible: function() {
495
+ vis = this.visible = !vis;
496
+ each(axis.series, function(series) {
497
+ each(series.points, function(point) {
498
+ if (point.dataClass === i) {
499
+ point.setVisible(vis);
500
+ }
501
+ });
502
+ });
503
+
504
+ chart.legend.colorizeItem(this, vis);
505
+ }
506
+ }, dataClass));
507
+ });
508
+ }
509
+ return legendItems;
510
+ },
511
+ name: '' // Prevents 'undefined' in legend in IE8
512
+ });
513
+
514
+ /**
515
+ * Handle animation of the color attributes directly
516
+ */
517
+ each(['fill', 'stroke'], function(prop) {
518
+ H.Fx.prototype[prop + 'Setter'] = function() {
519
+ this.elem.attr(
520
+ prop,
521
+ ColorAxis.prototype.tweenColors(
522
+ color(this.start),
523
+ color(this.end),
524
+ this.pos
525
+ ),
526
+ null,
527
+ true
528
+ );
529
+ };
530
+ });
531
+
532
+ /**
533
+ * Extend the chart getAxes method to also get the color axis
534
+ */
535
+ wrap(Chart.prototype, 'getAxes', function(proceed) {
536
+
537
+ var options = this.options,
538
+ colorAxisOptions = options.colorAxis;
539
+
540
+ proceed.call(this);
541
+
542
+ this.colorAxis = [];
543
+ if (colorAxisOptions) {
544
+ new ColorAxis(this, colorAxisOptions); // eslint-disable-line no-new
545
+ }
546
+ });
547
+
548
+
549
+ /**
550
+ * Wrap the legend getAllItems method to add the color axis. This also removes the
551
+ * axis' own series to prevent them from showing up individually.
552
+ */
553
+ wrap(Legend.prototype, 'getAllItems', function(proceed) {
554
+ var allItems = [],
555
+ colorAxis = this.chart.colorAxis[0];
556
+
557
+ if (colorAxis && colorAxis.options) {
558
+ if (colorAxis.options.showInLegend) {
559
+ // Data classes
560
+ if (colorAxis.options.dataClasses) {
561
+ allItems = allItems.concat(colorAxis.getDataClassLegendSymbols());
562
+ // Gradient legend
563
+ } else {
564
+ // Add this axis on top
565
+ allItems.push(colorAxis);
566
+ }
567
+ }
568
+
569
+ // Don't add the color axis' series
570
+ each(colorAxis.series, function(series) {
571
+ series.options.showInLegend = false;
572
+ });
573
+ }
574
+
575
+ return allItems.concat(proceed.call(this));
576
+ });
577
+
578
+ wrap(Legend.prototype, 'colorizeItem', function(proceed, item, visible) {
579
+ proceed.call(this, item, visible);
580
+ if (visible && item.legendColor) {
581
+ item.legendSymbol.attr({
582
+ fill: item.legendColor
583
+ });
584
+ }
585
+ });
586
+
587
+ }(Highcharts));
588
+ (function(H) {
589
+ /**
590
+ * (c) 2010-2016 Torstein Honsi
591
+ *
592
+ * License: www.highcharts.com/license
593
+ */
594
+ 'use strict';
595
+ var defined = H.defined,
596
+ each = H.each,
597
+ noop = H.noop,
598
+ seriesTypes = H.seriesTypes;
599
+
600
+ /**
601
+ * Mixin for maps and heatmaps
602
+ */
603
+ H.colorPointMixin = {
604
+ /**
605
+ * Color points have a value option that determines whether or not it is a null point
606
+ */
607
+ isValid: function() {
608
+ return this.value !== null;
609
+ },
610
+
611
+ /**
612
+ * Set the visibility of a single point
613
+ */
614
+ setVisible: function(vis) {
615
+ var point = this,
616
+ method = vis ? 'show' : 'hide';
617
+
618
+ // Show and hide associated elements
619
+ each(['graphic', 'dataLabel'], function(key) {
620
+ if (point[key]) {
621
+ point[key][method]();
622
+ }
623
+ });
624
+ },
625
+ setState: function(state) {
626
+ H.Point.prototype.setState.call(this, state);
627
+ if (this.graphic) {
628
+ this.graphic.attr({
629
+ zIndex: state === 'hover' ? 1 : 0
630
+ });
631
+ }
632
+ }
633
+ };
634
+
635
+ H.colorSeriesMixin = {
636
+ pointArrayMap: ['value'],
637
+ axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
638
+ optionalAxis: 'colorAxis',
639
+ trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
640
+ getSymbol: noop,
641
+ parallelArrays: ['x', 'y', 'value'],
642
+ colorKey: 'value',
643
+
644
+
645
+ pointAttribs: seriesTypes.column.prototype.pointAttribs,
646
+
647
+
648
+ /**
649
+ * In choropleth maps, the color is a result of the value, so this needs translation too
650
+ */
651
+ translateColors: function() {
652
+ var series = this,
653
+ nullColor = this.options.nullColor,
654
+ colorAxis = this.colorAxis,
655
+ colorKey = this.colorKey;
656
+
657
+ each(this.data, function(point) {
658
+ var value = point[colorKey],
659
+ color;
660
+
661
+ color = point.options.color ||
662
+ (point.isNull ? nullColor : (colorAxis && value !== undefined) ? colorAxis.toColor(value, point) : point.color || series.color);
663
+
664
+ if (color) {
665
+ point.color = color;
666
+ }
667
+ });
668
+ },
669
+
670
+ /**
671
+ * Get the color attibutes to apply on the graphic
672
+ */
673
+ colorAttribs: function(point) {
674
+ var ret = {};
675
+ if (defined(point.color)) {
676
+ ret[this.colorProp || 'fill'] = point.color;
677
+ }
678
+ return ret;
679
+ }
680
+ };
681
+
682
+ }(Highcharts));
683
+ (function(H) {
684
+ /**
685
+ * (c) 2010-2016 Torstein Honsi
686
+ *
687
+ * License: www.highcharts.com/license
688
+ */
689
+ 'use strict';
690
+ var colorPointMixin = H.colorPointMixin,
691
+ colorSeriesMixin = H.colorSeriesMixin,
692
+ each = H.each,
693
+ LegendSymbolMixin = H.LegendSymbolMixin,
694
+ merge = H.merge,
695
+ noop = H.noop,
696
+ pick = H.pick,
697
+ Series = H.Series,
698
+ seriesType = H.seriesType,
699
+ seriesTypes = H.seriesTypes;
700
+
701
+ // The Heatmap series type
702
+ seriesType('heatmap', 'scatter', {
703
+ animation: false,
704
+ borderWidth: 0,
705
+
706
+ nullColor: '#f7f7f7',
707
+
708
+ dataLabels: {
709
+ formatter: function() { // #2945
710
+ return this.point.value;
711
+ },
712
+ inside: true,
713
+ verticalAlign: 'middle',
714
+ crop: false,
715
+ overflow: false,
716
+ padding: 0 // #3837
717
+ },
718
+ marker: null,
719
+ pointRange: null, // dynamically set to colsize by default
720
+ tooltip: {
721
+ pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
722
+ },
723
+ states: {
724
+ normal: {
725
+ animation: true
726
+ },
727
+ hover: {
728
+ halo: false, // #3406, halo is not required on heatmaps
729
+ brightness: 0.2
730
+ }
731
+ }
732
+ }, merge(colorSeriesMixin, {
733
+ pointArrayMap: ['y', 'value'],
734
+ hasPointSpecificOptions: true,
735
+ supportsDrilldown: true,
736
+ getExtremesFromAll: true,
737
+ directTouch: true,
738
+
739
+ /**
740
+ * Override the init method to add point ranges on both axes.
741
+ */
742
+ init: function() {
743
+ var options;
744
+ seriesTypes.scatter.prototype.init.apply(this, arguments);
745
+
746
+ options = this.options;
747
+ options.pointRange = pick(options.pointRange, options.colsize || 1); // #3758, prevent resetting in setData
748
+ this.yAxis.axisPointRange = options.rowsize || 1; // general point range
749
+ },
750
+ translate: function() {
751
+ var series = this,
752
+ options = series.options,
753
+ xAxis = series.xAxis,
754
+ yAxis = series.yAxis,
755
+ between = function(x, a, b) {
756
+ return Math.min(Math.max(a, x), b);
757
+ };
758
+
759
+ series.generatePoints();
760
+
761
+ each(series.points, function(point) {
762
+ var xPad = (options.colsize || 1) / 2,
763
+ yPad = (options.rowsize || 1) / 2,
764
+ x1 = between(Math.round(xAxis.len - xAxis.translate(point.x - xPad, 0, 1, 0, 1)), -xAxis.len, 2 * xAxis.len),
765
+ x2 = between(Math.round(xAxis.len - xAxis.translate(point.x + xPad, 0, 1, 0, 1)), -xAxis.len, 2 * xAxis.len),
766
+ y1 = between(Math.round(yAxis.translate(point.y - yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len),
767
+ y2 = between(Math.round(yAxis.translate(point.y + yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len);
768
+
769
+ // Set plotX and plotY for use in K-D-Tree and more
770
+ point.plotX = point.clientX = (x1 + x2) / 2;
771
+ point.plotY = (y1 + y2) / 2;
772
+
773
+ point.shapeType = 'rect';
774
+ point.shapeArgs = {
775
+ x: Math.min(x1, x2),
776
+ y: Math.min(y1, y2),
777
+ width: Math.abs(x2 - x1),
778
+ height: Math.abs(y2 - y1)
779
+ };
780
+ });
781
+
782
+ series.translateColors();
783
+ },
784
+ drawPoints: function() {
785
+ seriesTypes.column.prototype.drawPoints.call(this);
786
+
787
+ each(this.points, function(point) {
788
+
789
+ point.graphic.attr(this.colorAttribs(point));
790
+
791
+ }, this);
792
+ },
793
+ animate: noop,
794
+ getBox: noop,
795
+ drawLegendSymbol: LegendSymbolMixin.drawRectangle,
796
+ alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
797
+ getExtremes: function() {
798
+ // Get the extremes from the value data
799
+ Series.prototype.getExtremes.call(this, this.valueData);
800
+ this.valueMin = this.dataMin;
801
+ this.valueMax = this.dataMax;
802
+
803
+ // Get the extremes from the y data
804
+ Series.prototype.getExtremes.call(this);
805
+ }
806
+
807
+ }), colorPointMixin);
808
+
809
+ }(Highcharts));
810
+ }));