highcharts-rails 5.0.14 → 6.0.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 (63) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.markdown +60 -0
  3. data/Rakefile +54 -5
  4. data/app/assets/images/highcharts/earth.svg +432 -0
  5. data/app/assets/javascripts/highcharts.js +5103 -3147
  6. data/app/assets/javascripts/highcharts/highcharts-3d.js +930 -277
  7. data/app/assets/javascripts/highcharts/highcharts-more.js +1374 -249
  8. data/app/assets/javascripts/highcharts/lib/canvg.js +3073 -0
  9. data/app/assets/javascripts/highcharts/lib/jspdf.js +16624 -0
  10. data/app/assets/javascripts/highcharts/lib/rgbcolor.js +299 -0
  11. data/app/assets/javascripts/highcharts/lib/svg2pdf.js +3488 -0
  12. data/app/assets/javascripts/highcharts/modules/accessibility.js +654 -212
  13. data/app/assets/javascripts/highcharts/modules/annotations.js +1552 -274
  14. data/app/assets/javascripts/highcharts/modules/boost-canvas.js +773 -0
  15. data/app/assets/javascripts/highcharts/modules/boost.js +636 -210
  16. data/app/assets/javascripts/highcharts/modules/broken-axis.js +2 -2
  17. data/app/assets/javascripts/highcharts/modules/bullet.js +364 -0
  18. data/app/assets/javascripts/highcharts/modules/data.js +766 -38
  19. data/app/assets/javascripts/highcharts/modules/drag-panes.js +588 -0
  20. data/app/assets/javascripts/highcharts/modules/drilldown.js +106 -36
  21. data/app/assets/javascripts/highcharts/modules/export-data.js +597 -0
  22. data/app/assets/javascripts/highcharts/modules/exporting.js +424 -162
  23. data/app/assets/javascripts/highcharts/modules/funnel.js +144 -22
  24. data/app/assets/javascripts/highcharts/modules/gantt.js +1154 -0
  25. data/app/assets/javascripts/highcharts/modules/grid-axis.js +1 -1
  26. data/app/assets/javascripts/highcharts/modules/heatmap.js +406 -80
  27. data/app/assets/javascripts/highcharts/modules/histogram-bellcurve.js +513 -0
  28. data/app/assets/javascripts/highcharts/modules/item-series.js +126 -0
  29. data/app/assets/javascripts/highcharts/modules/no-data-to-display.js +31 -13
  30. data/app/assets/javascripts/highcharts/modules/offline-exporting.js +179 -57
  31. data/app/assets/javascripts/highcharts/modules/oldie.js +1378 -0
  32. data/app/assets/javascripts/highcharts/modules/overlapping-datalabels.js +8 -6
  33. data/app/assets/javascripts/highcharts/modules/parallel-coordinates.js +494 -0
  34. data/app/assets/javascripts/highcharts/modules/pareto.js +275 -0
  35. data/app/assets/javascripts/highcharts/modules/sankey.js +641 -0
  36. data/app/assets/javascripts/highcharts/modules/series-label.js +355 -145
  37. data/app/assets/javascripts/highcharts/modules/solid-gauge.js +122 -1
  38. data/app/assets/javascripts/highcharts/modules/static-scale.js +64 -0
  39. data/app/assets/javascripts/highcharts/modules/stock.js +1944 -676
  40. data/app/assets/javascripts/highcharts/modules/streamgraph.js +139 -0
  41. data/app/assets/javascripts/highcharts/modules/sunburst.js +2403 -0
  42. data/app/assets/javascripts/highcharts/modules/tilemap.js +1199 -0
  43. data/app/assets/javascripts/highcharts/modules/treemap.js +538 -134
  44. data/app/assets/javascripts/highcharts/modules/variable-pie.js +490 -0
  45. data/app/assets/javascripts/highcharts/modules/variwide.js +283 -0
  46. data/app/assets/javascripts/highcharts/modules/vector.js +294 -0
  47. data/app/assets/javascripts/highcharts/modules/windbarb.js +490 -0
  48. data/app/assets/javascripts/highcharts/modules/wordcloud.js +681 -0
  49. data/app/assets/javascripts/highcharts/modules/xrange.js +615 -0
  50. data/app/assets/javascripts/highcharts/themes/avocado.js +54 -0
  51. data/app/assets/javascripts/highcharts/themes/dark-blue.js +6 -6
  52. data/app/assets/javascripts/highcharts/themes/dark-green.js +6 -6
  53. data/app/assets/javascripts/highcharts/themes/dark-unica.js +6 -6
  54. data/app/assets/javascripts/highcharts/themes/gray.js +14 -10
  55. data/app/assets/javascripts/highcharts/themes/grid-light.js +6 -6
  56. data/app/assets/javascripts/highcharts/themes/grid.js +7 -5
  57. data/app/assets/javascripts/highcharts/themes/sand-signika.js +8 -7
  58. data/app/assets/javascripts/highcharts/themes/skies.js +15 -9
  59. data/app/assets/javascripts/highcharts/themes/sunset.js +53 -0
  60. data/app/assets/stylesheets/highcharts/highcharts.css +802 -0
  61. data/app/assets/stylesheets/highcharts/highcharts.scss +665 -0
  62. data/lib/highcharts/version.rb +1 -1
  63. metadata +31 -1
@@ -0,0 +1,1199 @@
1
+ /**
2
+ * @license Highcharts JS v6.0.0 (2017-10-04)
3
+ * Tilemap module
4
+ *
5
+ * (c) 2010-2017 Highsoft AS
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) 2010-2017 Torstein Honsi
20
+ *
21
+ * License: www.highcharts.com/license
22
+ */
23
+ var defined = H.defined,
24
+ each = H.each,
25
+ noop = H.noop,
26
+ seriesTypes = H.seriesTypes;
27
+
28
+ /**
29
+ * Mixin for maps and heatmaps
30
+ */
31
+ H.colorPointMixin = {
32
+ /**
33
+ * Color points have a value option that determines whether or not it is
34
+ * a null point
35
+ */
36
+ isValid: function() {
37
+ return this.value !== null;
38
+ },
39
+
40
+ /**
41
+ * Set the visibility of a single point
42
+ */
43
+ setVisible: function(vis) {
44
+ var point = this,
45
+ method = vis ? 'show' : 'hide';
46
+
47
+ // Show and hide associated elements
48
+ each(['graphic', 'dataLabel'], function(key) {
49
+ if (point[key]) {
50
+ point[key][method]();
51
+ }
52
+ });
53
+ },
54
+ setState: function(state) {
55
+ H.Point.prototype.setState.call(this, state);
56
+ if (this.graphic) {
57
+ this.graphic.attr({
58
+ zIndex: state === 'hover' ? 1 : 0
59
+ });
60
+ }
61
+ }
62
+ };
63
+
64
+ H.colorSeriesMixin = {
65
+ pointArrayMap: ['value'],
66
+ axisTypes: ['xAxis', 'yAxis', 'colorAxis'],
67
+ optionalAxis: 'colorAxis',
68
+ trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
69
+ getSymbol: noop,
70
+ parallelArrays: ['x', 'y', 'value'],
71
+ colorKey: 'value',
72
+
73
+
74
+ pointAttribs: seriesTypes.column.prototype.pointAttribs,
75
+
76
+
77
+ /**
78
+ * In choropleth maps, the color is a result of the value, so this needs
79
+ * translation too
80
+ */
81
+ translateColors: function() {
82
+ var series = this,
83
+ nullColor = this.options.nullColor,
84
+ colorAxis = this.colorAxis,
85
+ colorKey = this.colorKey;
86
+
87
+ each(this.data, function(point) {
88
+ var value = point[colorKey],
89
+ color;
90
+
91
+ color = point.options.color ||
92
+ (
93
+ point.isNull ?
94
+ nullColor :
95
+ (colorAxis && value !== undefined) ?
96
+ colorAxis.toColor(value, point) :
97
+ point.color || series.color
98
+ );
99
+
100
+ if (color) {
101
+ point.color = color;
102
+ }
103
+ });
104
+ },
105
+
106
+ /**
107
+ * Get the color attibutes to apply on the graphic
108
+ */
109
+ colorAttribs: function(point) {
110
+ var ret = {};
111
+ if (defined(point.color)) {
112
+ ret[this.colorProp || 'fill'] = point.color;
113
+ }
114
+ return ret;
115
+ }
116
+ };
117
+
118
+ }(Highcharts));
119
+ (function(H) {
120
+ /**
121
+ * (c) 2010-2017 Torstein Honsi
122
+ *
123
+ * License: www.highcharts.com/license
124
+ */
125
+ var colorPointMixin = H.colorPointMixin,
126
+ colorSeriesMixin = H.colorSeriesMixin,
127
+ each = H.each,
128
+ LegendSymbolMixin = H.LegendSymbolMixin,
129
+ merge = H.merge,
130
+ noop = H.noop,
131
+ pick = H.pick,
132
+ Series = H.Series,
133
+ seriesType = H.seriesType,
134
+ seriesTypes = H.seriesTypes;
135
+
136
+
137
+ /**
138
+ * A heatmap is a graphical representation of data where the individual values
139
+ * contained in a matrix are represented as colors.
140
+ *
141
+ * @sample highcharts/demo/heatmap/
142
+ * Simple heatmap
143
+ * @sample highcharts/demo/heatmap-canvas/
144
+ * Heavy heatmap
145
+ * @extends {plotOptions.scatter}
146
+ * @excluding marker,pointRange
147
+ * @product highcharts highmaps
148
+ * @optionparent plotOptions.heatmap
149
+ */
150
+ seriesType('heatmap', 'scatter', {
151
+
152
+ /**
153
+ * Animation is disabled by default on the heatmap series.
154
+ */
155
+ animation: false,
156
+
157
+ /**
158
+ * The border width for each heat map item.
159
+ */
160
+ borderWidth: 0,
161
+
162
+ /**
163
+ * Padding between the points in the heatmap.
164
+ *
165
+ * @type {Number}
166
+ * @default 0
167
+ * @since 6.0
168
+ * @apioption plotOptions.heatmap.pointPadding
169
+ */
170
+
171
+ /**
172
+ * The main color of the series. In heat maps this color is rarely used,
173
+ * as we mostly use the color to denote the value of each point. Unless
174
+ * options are set in the [colorAxis](#colorAxis), the default value
175
+ * is pulled from the [options.colors](#colors) array.
176
+ *
177
+ * @type {Color}
178
+ * @default null
179
+ * @since 4.0
180
+ * @product highcharts
181
+ * @apioption plotOptions.heatmap.color
182
+ */
183
+
184
+ /**
185
+ * The column size - how many X axis units each column in the heatmap
186
+ * should span.
187
+ *
188
+ * @type {Number}
189
+ * @sample {highcharts} maps/demo/heatmap/ One day
190
+ * @sample {highmaps} maps/demo/heatmap/ One day
191
+ * @default 1
192
+ * @since 4.0
193
+ * @product highcharts highmaps
194
+ * @apioption plotOptions.heatmap.colsize
195
+ */
196
+
197
+
198
+
199
+ /**
200
+ * The color applied to null points. In styled mode, a general CSS class is
201
+ * applied instead.
202
+ *
203
+ * @type {Color}
204
+ */
205
+ nullColor: '#f7f7f7',
206
+
207
+
208
+ dataLabels: {
209
+
210
+ formatter: function() { // #2945
211
+ return this.point.value;
212
+ },
213
+ inside: true,
214
+ verticalAlign: 'middle',
215
+ crop: false,
216
+ overflow: false,
217
+ padding: 0 // #3837
218
+ },
219
+
220
+ /** @ignore */
221
+ marker: null,
222
+
223
+ /** @ignore */
224
+ pointRange: null, // dynamically set to colsize by default
225
+
226
+ tooltip: {
227
+ pointFormat: '{point.x}, {point.y}: {point.value}<br/>'
228
+ },
229
+
230
+ states: {
231
+
232
+ normal: {
233
+ animation: true
234
+ },
235
+
236
+ hover: {
237
+ halo: false, // #3406, halo is disabled on heatmaps by default
238
+ brightness: 0.2
239
+ }
240
+ }
241
+ /**
242
+ * The row size - how many Y axis units each heatmap row should span.
243
+ *
244
+ * @type {Number}
245
+ * @sample {highcharts} maps/demo/heatmap/ 1 by default
246
+ * @sample {highmaps} maps/demo/heatmap/ 1 by default
247
+ * @default 1
248
+ * @since 4.0
249
+ * @product highcharts highmaps
250
+ * @apioption plotOptions.heatmap.rowsize
251
+ */
252
+
253
+ }, merge(colorSeriesMixin, {
254
+ pointArrayMap: ['y', 'value'],
255
+ hasPointSpecificOptions: true,
256
+ getExtremesFromAll: true,
257
+ directTouch: true,
258
+
259
+ /**
260
+ * Override the init method to add point ranges on both axes.
261
+ */
262
+ init: function() {
263
+ var options;
264
+ seriesTypes.scatter.prototype.init.apply(this, arguments);
265
+
266
+ options = this.options;
267
+ // #3758, prevent resetting in setData
268
+ options.pointRange = pick(options.pointRange, options.colsize || 1);
269
+ this.yAxis.axisPointRange = options.rowsize || 1; // general point range
270
+ },
271
+ translate: function() {
272
+ var series = this,
273
+ options = series.options,
274
+ xAxis = series.xAxis,
275
+ yAxis = series.yAxis,
276
+ seriesPointPadding = options.pointPadding || 0,
277
+ between = function(x, a, b) {
278
+ return Math.min(Math.max(a, x), b);
279
+ };
280
+
281
+ series.generatePoints();
282
+
283
+ each(series.points, function(point) {
284
+ var xPad = (options.colsize || 1) / 2,
285
+ yPad = (options.rowsize || 1) / 2,
286
+ x1 = between(
287
+ Math.round(
288
+ xAxis.len -
289
+ xAxis.translate(point.x - xPad, 0, 1, 0, 1)
290
+ ), -xAxis.len, 2 * xAxis.len
291
+ ),
292
+ x2 = between(
293
+ Math.round(
294
+ xAxis.len -
295
+ xAxis.translate(point.x + xPad, 0, 1, 0, 1)
296
+ ), -xAxis.len, 2 * xAxis.len
297
+ ),
298
+ y1 = between(
299
+ Math.round(yAxis.translate(point.y - yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len
300
+ ),
301
+ y2 = between(
302
+ Math.round(yAxis.translate(point.y + yPad, 0, 1, 0, 1)), -yAxis.len, 2 * yAxis.len
303
+ ),
304
+ pointPadding = pick(point.pointPadding, seriesPointPadding);
305
+
306
+ // Set plotX and plotY for use in K-D-Tree and more
307
+ point.plotX = point.clientX = (x1 + x2) / 2;
308
+ point.plotY = (y1 + y2) / 2;
309
+
310
+ point.shapeType = 'rect';
311
+ point.shapeArgs = {
312
+ x: Math.min(x1, x2) + pointPadding,
313
+ y: Math.min(y1, y2) + pointPadding,
314
+ width: Math.abs(x2 - x1) - pointPadding * 2,
315
+ height: Math.abs(y2 - y1) - pointPadding * 2
316
+ };
317
+ });
318
+
319
+ series.translateColors();
320
+ },
321
+ drawPoints: function() {
322
+ seriesTypes.column.prototype.drawPoints.call(this);
323
+
324
+ each(this.points, function(point) {
325
+
326
+ point.graphic.attr(this.colorAttribs(point));
327
+
328
+ }, this);
329
+ },
330
+ animate: noop,
331
+ getBox: noop,
332
+ drawLegendSymbol: LegendSymbolMixin.drawRectangle,
333
+ alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
334
+ getExtremes: function() {
335
+ // Get the extremes from the value data
336
+ Series.prototype.getExtremes.call(this, this.valueData);
337
+ this.valueMin = this.dataMin;
338
+ this.valueMax = this.dataMax;
339
+
340
+ // Get the extremes from the y data
341
+ Series.prototype.getExtremes.call(this);
342
+ }
343
+
344
+ }), H.extend({
345
+ haloPath: function(size) {
346
+ if (!size) {
347
+ return [];
348
+ }
349
+ var rect = this.shapeArgs;
350
+ return [
351
+ 'M', rect.x - size, rect.y - size,
352
+ 'L', rect.x - size, rect.y + rect.height + size,
353
+ rect.x + rect.width + size, rect.y + rect.height + size,
354
+ rect.x + rect.width + size, rect.y - size,
355
+ 'Z'
356
+ ];
357
+ }
358
+ }, colorPointMixin));
359
+ /**
360
+ * A `heatmap` series. If the [type](#series.heatmap.type) option is
361
+ * not specified, it is inherited from [chart.type](#chart.type).
362
+ *
363
+ * For options that apply to multiple series, it is recommended to add
364
+ * them to the [plotOptions.series](#plotOptions.series) options structure.
365
+ * To apply to all series of this specific type, apply it to [plotOptions.
366
+ * heatmap](#plotOptions.heatmap).
367
+ *
368
+ * @type {Object}
369
+ * @extends series,plotOptions.heatmap
370
+ * @excluding dataParser,dataURL,stack
371
+ * @product highcharts highmaps
372
+ * @apioption series.heatmap
373
+ */
374
+
375
+ /**
376
+ * An array of data points for the series. For the `heatmap` series
377
+ * type, points can be given in the following ways:
378
+ *
379
+ * 1. An array of arrays with 3 or 2 values. In this case, the values
380
+ * correspond to `x,y,value`. If the first value is a string, it is
381
+ * applied as the name of the point, and the `x` value is inferred.
382
+ * The `x` value can also be omitted, in which case the inner arrays
383
+ * should be of length 2\. Then the `x` value is automatically calculated,
384
+ * either starting at 0 and incremented by 1, or from `pointStart`
385
+ * and `pointInterval` given in the series options.
386
+ *
387
+ * ```js
388
+ * data: [
389
+ * [0, 9, 7],
390
+ * [1, 10, 4],
391
+ * [2, 6, 3]
392
+ * ]
393
+ * ```
394
+ *
395
+ * 2. An array of objects with named values. The objects are point
396
+ * configuration objects as seen below. If the total number of data
397
+ * points exceeds the series' [turboThreshold](#series.heatmap.turboThreshold),
398
+ * this option is not available.
399
+ *
400
+ * ```js
401
+ * data: [{
402
+ * x: 1,
403
+ * y: 3,
404
+ * value: 10,
405
+ * name: "Point2",
406
+ * color: "#00FF00"
407
+ * }, {
408
+ * x: 1,
409
+ * y: 7,
410
+ * value: 10,
411
+ * name: "Point1",
412
+ * color: "#FF00FF"
413
+ * }]
414
+ * ```
415
+ *
416
+ * @type {Array<Object|Array>}
417
+ * @extends series.line.data
418
+ * @excluding marker
419
+ * @sample {highcharts} highcharts/chart/reflow-true/ Numerical values
420
+ * @sample {highcharts} highcharts/series/data-array-of-arrays/ Arrays of numeric x and y
421
+ * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/ Arrays of datetime x and y
422
+ * @sample {highcharts} highcharts/series/data-array-of-name-value/ Arrays of point.name and y
423
+ * @sample {highcharts} highcharts/series/data-array-of-objects/ Config objects
424
+ * @product highcharts highmaps
425
+ * @apioption series.heatmap.data
426
+ */
427
+
428
+ /**
429
+ * The color of the point. In heat maps the point color is rarely set
430
+ * explicitly, as we use the color to denote the `value`. Options for
431
+ * this are set in the [colorAxis](#colorAxis) configuration.
432
+ *
433
+ * @type {Color}
434
+ * @product highcharts highmaps
435
+ * @apioption series.heatmap.data.color
436
+ */
437
+
438
+ /**
439
+ * The value of the point, resulting in a color controled by options
440
+ * as set in the [colorAxis](#colorAxis) configuration.
441
+ *
442
+ * @type {Number}
443
+ * @product highcharts highmaps
444
+ * @apioption series.heatmap.data.value
445
+ */
446
+
447
+ /**
448
+ * The x coordinate of the point.
449
+ *
450
+ * @type {Number}
451
+ * @product highmaps
452
+ * @apioption series.heatmap.data.x
453
+ */
454
+
455
+ /**
456
+ * The y coordinate of the point.
457
+ *
458
+ * @type {Number}
459
+ * @product highmaps
460
+ * @apioption series.heatmap.data.y
461
+ */
462
+
463
+ /**
464
+ * Point padding for a single point.
465
+ *
466
+ * @type {Number}
467
+ * @sample maps/plotoptions/tilemap-pointpadding Point padding on tiles
468
+ * @apioption series.heatmap.data.pointPadding
469
+ */
470
+
471
+
472
+ }(Highcharts));
473
+ (function(H) {
474
+ /**
475
+ * Tilemaps module
476
+ *
477
+ * (c) 2010-2017 Highsoft AS
478
+ * Author: Øystein Moseng
479
+ *
480
+ * License: www.highcharts.com/license
481
+ */
482
+
483
+ var seriesType = H.seriesType,
484
+ each = H.each,
485
+ reduce = H.reduce,
486
+ pick = H.pick,
487
+ // Utility func to get the middle number of 3
488
+ between = function(x, a, b) {
489
+ return Math.min(Math.max(a, x), b);
490
+ },
491
+ // Utility func to get padding definition from tile size division
492
+ tilePaddingFromTileSize = function(series, xDiv, yDiv) {
493
+ var options = series.options;
494
+ return {
495
+ xPad: (options.colsize || 1) / -xDiv,
496
+ yPad: (options.rowsize || 1) / -yDiv
497
+ };
498
+ };
499
+
500
+ // Map of shape types
501
+ H.tileShapeTypes = {
502
+
503
+ /** Hexagon shape type **/
504
+ hexagon: {
505
+ alignDataLabel: H.seriesTypes.scatter.prototype.alignDataLabel,
506
+ getSeriesPadding: function(series) {
507
+ return tilePaddingFromTileSize(series, 3, 2);
508
+ },
509
+ haloPath: function(size) {
510
+ if (!size) {
511
+ return [];
512
+ }
513
+ var hexagon = this.tileEdges;
514
+ return [
515
+ 'M', hexagon.x2 - size, hexagon.y1 + size,
516
+ 'L', hexagon.x3 + size, hexagon.y1 + size,
517
+ hexagon.x4 + size * 1.5, hexagon.y2,
518
+ hexagon.x3 + size, hexagon.y3 - size,
519
+ hexagon.x2 - size, hexagon.y3 - size,
520
+ hexagon.x1 - size * 1.5, hexagon.y2,
521
+ 'Z'
522
+ ];
523
+ },
524
+ translate: function() {
525
+ var series = this,
526
+ options = series.options,
527
+ xAxis = series.xAxis,
528
+ yAxis = series.yAxis,
529
+ seriesPointPadding = options.pointPadding || 0,
530
+ xPad = (options.colsize || 1) / 3,
531
+ yPad = (options.rowsize || 1) / 2,
532
+ yShift;
533
+
534
+ series.generatePoints();
535
+
536
+ each(series.points, function(point) {
537
+ var x1 = between(
538
+ Math.floor(
539
+ xAxis.len -
540
+ xAxis.translate(point.x - xPad * 2, 0, 1, 0, 1)
541
+ ), -xAxis.len, 2 * xAxis.len
542
+ ),
543
+ x2 = between(
544
+ Math.floor(
545
+ xAxis.len -
546
+ xAxis.translate(point.x - xPad, 0, 1, 0, 1)
547
+ ), -xAxis.len, 2 * xAxis.len
548
+ ),
549
+ x3 = between(
550
+ Math.floor(
551
+ xAxis.len -
552
+ xAxis.translate(point.x + xPad, 0, 1, 0, 1)
553
+ ), -xAxis.len, 2 * xAxis.len
554
+ ),
555
+ x4 = between(
556
+ Math.floor(
557
+ xAxis.len -
558
+ xAxis.translate(point.x + xPad * 2, 0, 1, 0, 1)
559
+ ), -xAxis.len, 2 * xAxis.len
560
+ ),
561
+ y1 = between(
562
+ Math.floor(yAxis.translate(point.y - yPad, 0, 1, 0, 1)), -yAxis.len,
563
+ 2 * yAxis.len
564
+ ),
565
+ y2 = between(
566
+ Math.floor(yAxis.translate(point.y, 0, 1, 0, 1)), -yAxis.len,
567
+ 2 * yAxis.len
568
+ ),
569
+ y3 = between(
570
+ Math.floor(yAxis.translate(point.y + yPad, 0, 1, 0, 1)), -yAxis.len,
571
+ 2 * yAxis.len
572
+ ),
573
+ pointPadding = pick(point.pointPadding, seriesPointPadding),
574
+ // We calculate the point padding of the midpoints to
575
+ // preserve the angles of the shape.
576
+ midPointPadding = pointPadding *
577
+ Math.abs(x2 - x1) / Math.abs(y3 - y2),
578
+ xMidPadding = xAxis.reversed ?
579
+ -midPointPadding : midPointPadding,
580
+ xPointPadding = xAxis.reversed ?
581
+ -pointPadding : pointPadding,
582
+ yPointPadding = yAxis.reversed ?
583
+ -pointPadding : pointPadding;
584
+
585
+ // Shift y-values for every second grid column
586
+ if (point.x % 2) {
587
+ yShift = yShift || Math.round(Math.abs(y3 - y1) / 2) *
588
+ // We have to reverse the shift for reversed y-axes
589
+ (yAxis.reversed ? -1 : 1);
590
+ y1 += yShift;
591
+ y2 += yShift;
592
+ y3 += yShift;
593
+ }
594
+
595
+ // Set plotX and plotY for use in K-D-Tree and more
596
+ point.plotX = point.clientX = (x2 + x3) / 2;
597
+ point.plotY = y2;
598
+
599
+ // Apply point padding to translated coordinates
600
+ x1 += xMidPadding + xPointPadding;
601
+ x2 += xPointPadding;
602
+ x3 -= xPointPadding;
603
+ x4 -= xMidPadding + xPointPadding;
604
+ y1 -= yPointPadding;
605
+ y3 += yPointPadding;
606
+
607
+ // Store points for halo creation
608
+ point.tileEdges = {
609
+ x1: x1,
610
+ x2: x2,
611
+ x3: x3,
612
+ x4: x4,
613
+ y1: y1,
614
+ y2: y2,
615
+ y3: y3
616
+ };
617
+
618
+ // Finally set the shape for this point
619
+ point.shapeType = 'path';
620
+ point.shapeArgs = {
621
+ d: [
622
+ 'M', x2, y1,
623
+ 'L', x3, y1,
624
+ x4, y2,
625
+ x3, y3,
626
+ x2, y3,
627
+ x1, y2,
628
+ 'Z'
629
+ ]
630
+ };
631
+ });
632
+
633
+ series.translateColors();
634
+ }
635
+ },
636
+
637
+
638
+ /** Diamond shape type **/
639
+ diamond: {
640
+ alignDataLabel: H.seriesTypes.scatter.prototype.alignDataLabel,
641
+ getSeriesPadding: function(series) {
642
+ return tilePaddingFromTileSize(series, 2, 2);
643
+ },
644
+ haloPath: function(size) {
645
+ if (!size) {
646
+ return [];
647
+ }
648
+ var diamond = this.tileEdges;
649
+ return [
650
+ 'M', diamond.x2, diamond.y1 + size,
651
+ 'L', diamond.x3 + size, diamond.y2,
652
+ diamond.x2, diamond.y3 - size,
653
+ diamond.x1 - size, diamond.y2,
654
+ 'Z'
655
+ ];
656
+ },
657
+ translate: function() {
658
+ var series = this,
659
+ options = series.options,
660
+ xAxis = series.xAxis,
661
+ yAxis = series.yAxis,
662
+ seriesPointPadding = options.pointPadding || 0,
663
+ xPad = (options.colsize || 1),
664
+ yPad = (options.rowsize || 1) / 2,
665
+ yShift;
666
+
667
+ series.generatePoints();
668
+
669
+ each(series.points, function(point) {
670
+ var x1 = between(
671
+ Math.round(
672
+ xAxis.len -
673
+ xAxis.translate(point.x - xPad, 0, 1, 0, 0)
674
+ ), -xAxis.len, 2 * xAxis.len
675
+ ),
676
+ x2 = between(
677
+ Math.round(
678
+ xAxis.len -
679
+ xAxis.translate(point.x, 0, 1, 0, 0)
680
+ ), -xAxis.len, 2 * xAxis.len
681
+ ),
682
+ x3 = between(
683
+ Math.round(
684
+ xAxis.len -
685
+ xAxis.translate(point.x + xPad, 0, 1, 0, 0)
686
+ ), -xAxis.len, 2 * xAxis.len
687
+ ),
688
+ y1 = between(
689
+ Math.round(yAxis.translate(point.y - yPad, 0, 1, 0, 0)), -yAxis.len,
690
+ 2 * yAxis.len
691
+ ),
692
+ y2 = between(
693
+ Math.round(yAxis.translate(point.y, 0, 1, 0, 0)), -yAxis.len,
694
+ 2 * yAxis.len
695
+ ),
696
+ y3 = between(
697
+ Math.round(yAxis.translate(point.y + yPad, 0, 1, 0, 0)), -yAxis.len,
698
+ 2 * yAxis.len
699
+ ),
700
+ pointPadding = pick(point.pointPadding, seriesPointPadding),
701
+ // We calculate the point padding of the midpoints to
702
+ // preserve the angles of the shape.
703
+ midPointPadding = pointPadding *
704
+ Math.abs(x2 - x1) / Math.abs(y3 - y2),
705
+ xPointPadding = xAxis.reversed ?
706
+ -midPointPadding : midPointPadding,
707
+ yPointPadding = yAxis.reversed ?
708
+ -pointPadding : pointPadding;
709
+
710
+ // Shift y-values for every second grid column
711
+ // We have to reverse the shift for reversed y-axes
712
+ if (point.x % 2) {
713
+ yShift = Math.abs(y3 - y1) / 2 * (yAxis.reversed ? -1 : 1);
714
+ y1 += yShift;
715
+ y2 += yShift;
716
+ y3 += yShift;
717
+ }
718
+
719
+ // Set plotX and plotY for use in K-D-Tree and more
720
+ point.plotX = point.clientX = x2;
721
+ point.plotY = y2;
722
+
723
+ // Apply point padding to translated coordinates
724
+ x1 += xPointPadding;
725
+ x3 -= xPointPadding;
726
+ y1 -= yPointPadding;
727
+ y3 += yPointPadding;
728
+
729
+ // Store points for halo creation
730
+ point.tileEdges = {
731
+ x1: x1,
732
+ x2: x2,
733
+ x3: x3,
734
+ y1: y1,
735
+ y2: y2,
736
+ y3: y3
737
+ };
738
+
739
+ // Set this point's shape parameters
740
+ point.shapeType = 'path';
741
+ point.shapeArgs = {
742
+ d: [
743
+ 'M', x2, y1,
744
+ 'L', x3, y2,
745
+ x2, y3,
746
+ x1, y2,
747
+ 'Z'
748
+ ]
749
+ };
750
+ });
751
+
752
+ series.translateColors();
753
+ }
754
+ },
755
+
756
+
757
+ /** Circle shape type **/
758
+ circle: {
759
+ alignDataLabel: H.seriesTypes.scatter.prototype.alignDataLabel,
760
+ getSeriesPadding: function(series) {
761
+ return tilePaddingFromTileSize(series, 2, 2);
762
+ },
763
+ haloPath: function(size) {
764
+ return H.seriesTypes.scatter.prototype.pointClass.prototype.haloPath
765
+ .call(this,
766
+ size + (size && this.radius)
767
+ );
768
+ },
769
+ translate: function() {
770
+ var series = this,
771
+ options = series.options,
772
+ xAxis = series.xAxis,
773
+ yAxis = series.yAxis,
774
+ seriesPointPadding = options.pointPadding || 0,
775
+ yRadius = (options.rowsize || 1) / 2,
776
+ colsize = (options.colsize || 1),
777
+ colsizePx,
778
+ yRadiusPx,
779
+ xRadiusPx,
780
+ radius,
781
+ forceNextRadiusCompute = false;
782
+
783
+ series.generatePoints();
784
+
785
+ each(series.points, function(point) {
786
+ var x = between(
787
+ Math.round(
788
+ xAxis.len -
789
+ xAxis.translate(point.x, 0, 1, 0, 0)
790
+ ), -xAxis.len, 2 * xAxis.len
791
+ ),
792
+ y = between(
793
+ Math.round(yAxis.translate(point.y, 0, 1, 0, 0)), -yAxis.len,
794
+ 2 * yAxis.len
795
+ ),
796
+ pointPadding = seriesPointPadding,
797
+ hasPerPointPadding = false;
798
+
799
+ // If there is point padding defined on a single point, add it
800
+ if (point.pointPadding !== undefined) {
801
+ pointPadding = point.pointPadding;
802
+ hasPerPointPadding = true;
803
+ forceNextRadiusCompute = true;
804
+ }
805
+
806
+ // Find radius if not found already.
807
+ // Use the smallest one (x vs y) to avoid overlap.
808
+ // Note that the radius will be recomputed for each series.
809
+ // Ideal (max) x radius is dependent on y radius:
810
+ /*
811
+ * (circle 2)
812
+
813
+ * (circle 3)
814
+ | yRadiusPx
815
+ (circle 1) *-------|
816
+ colsizePx
817
+
818
+ The distance between circle 1 and 3 (and circle 2 and 3) is
819
+ 2r, which is the hypotenuse of the triangle created by
820
+ colsizePx and yRadiusPx. If the distance between circle 2
821
+ and circle 1 is less than 2r, we use half of that distance
822
+ instead (yRadiusPx).
823
+ */
824
+ if (!radius || forceNextRadiusCompute) {
825
+ colsizePx = Math.abs(
826
+ between(
827
+ Math.floor(
828
+ xAxis.len -
829
+ xAxis.translate(point.x + colsize, 0, 1, 0, 0)
830
+ ), -xAxis.len, 2 * xAxis.len
831
+ ) - x
832
+ );
833
+ yRadiusPx = Math.abs(
834
+ between(
835
+ Math.floor(
836
+ yAxis.translate(point.y + yRadius, 0, 1, 0, 0)
837
+ ), -yAxis.len, 2 * yAxis.len
838
+ ) - y
839
+ );
840
+ xRadiusPx = Math.floor(
841
+ Math.sqrt(
842
+ (colsizePx * colsizePx + yRadiusPx * yRadiusPx)
843
+ ) / 2
844
+ );
845
+ radius = Math.min(
846
+ colsizePx, xRadiusPx, yRadiusPx
847
+ ) - pointPadding;
848
+
849
+ // If we have per point padding we need to always compute
850
+ // the radius for this point and the next. If we used to
851
+ // have per point padding but don't anymore, don't force
852
+ // compute next radius.
853
+ if (forceNextRadiusCompute && !hasPerPointPadding) {
854
+ forceNextRadiusCompute = false;
855
+ }
856
+ }
857
+
858
+ // Shift y-values for every second grid column.
859
+ // Note that we always use the optimal y axis radius for this.
860
+ // Also note: We have to reverse the shift for reversed y-axes.
861
+ if (point.x % 2) {
862
+ y += yRadiusPx * (yAxis.reversed ? -1 : 1);
863
+ }
864
+
865
+ // Set plotX and plotY for use in K-D-Tree and more
866
+ point.plotX = point.clientX = x;
867
+ point.plotY = y;
868
+
869
+ // Save radius for halo
870
+ point.radius = radius;
871
+
872
+ // Set this point's shape parameters
873
+ point.shapeType = 'circle';
874
+ point.shapeArgs = {
875
+ x: x,
876
+ y: y,
877
+ r: radius
878
+ };
879
+ });
880
+
881
+ series.translateColors();
882
+ }
883
+ },
884
+
885
+
886
+ /** Square shape type **/
887
+ square: {
888
+ alignDataLabel: H.seriesTypes.heatmap.prototype.alignDataLabel,
889
+ translate: H.seriesTypes.heatmap.prototype.translate,
890
+ getSeriesPadding: function() {
891
+ return;
892
+ },
893
+ haloPath: H.seriesTypes.heatmap.prototype.pointClass.prototype.haloPath
894
+ }
895
+ };
896
+
897
+
898
+ // Extension to add pixel padding for series. Uses getSeriesPixelPadding on each
899
+ // series and adds the largest padding required. If no series has this function
900
+ // defined, we add nothing.
901
+ H.wrap(H.Axis.prototype, 'setAxisTranslation', function(proceed) {
902
+
903
+ // We need to run the original func first, so that we know the translation
904
+ // formula to use for computing the padding
905
+ proceed.apply(this, Array.prototype.slice.call(arguments, 1));
906
+
907
+ var axis = this,
908
+ // Find which series' padding to use
909
+ seriesPadding = reduce(H.map(axis.series, function(series) {
910
+ return series.getSeriesPixelPadding &&
911
+ series.getSeriesPixelPadding(axis);
912
+ }), function(a, b) {
913
+ return (a && a.padding) > (b && b.padding) ? a : b;
914
+ }) || {
915
+ padding: 0,
916
+ axisLengthFactor: 1
917
+ },
918
+ lengthPadding = Math.round(
919
+ seriesPadding.padding * seriesPadding.axisLengthFactor
920
+ );
921
+
922
+ // Don't waste time on this if we're not adding extra padding
923
+ if (seriesPadding.padding) {
924
+ // Recompute translation with new axis length now (minus padding)
925
+ axis.len -= lengthPadding;
926
+ proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
927
+ axis.minPixelPadding += seriesPadding.padding;
928
+ axis.len += lengthPadding;
929
+ }
930
+ });
931
+
932
+
933
+ /**
934
+ * A tilemap series is a type of heatmap where the tile shapes are configurable.
935
+ *
936
+ * @extends {plotOptions.heatmap}
937
+ * @product highcharts highmaps
938
+ * @sample highcharts/demo/honeycomb-usa/
939
+ * Honeycomb tilemap, USA
940
+ * @sample maps/plotoptions/honeycomb-brazil/
941
+ * Honeycomb tilemap, Brazil
942
+ * @sample maps/plotoptions/honeycomb-china/
943
+ * Honeycomb tilemap, China
944
+ * @sample maps/plotoptions/honeycomb-europe/
945
+ * Honeycomb tilemap, Europe
946
+ * @sample maps/demo/circlemap-africa/
947
+ * Circlemap tilemap, Africa
948
+ * @sample maps/demo/diamondmap
949
+ * Diamondmap tilemap
950
+ * @since 6.0.0
951
+ * @excluding joinBy, shadow, allAreas, mapData
952
+ * @optionparent plotOptions.tilemap
953
+ */
954
+ seriesType('tilemap', 'heatmap', {
955
+ // Default options
956
+ states: {
957
+ hover: {
958
+ halo: {
959
+ enabled: true,
960
+ size: 2,
961
+ opacity: 0.5,
962
+ attributes: {
963
+ zIndex: 3
964
+ }
965
+ }
966
+ }
967
+ },
968
+
969
+ /**
970
+ * The padding between points in the tilemap.
971
+ *
972
+ * @sample maps/plotoptions/tilemap-pointpadding Point padding on tiles
973
+ */
974
+ pointPadding: 2,
975
+
976
+ /**
977
+ * The shape of the tiles in the tilemap. Possible values are `hexagon`,
978
+ * `circle`, `diamond`, and `square`.
979
+ *
980
+ * @sample maps/demo/circlemap-africa Circular tile shapes
981
+ * @sample maps/demo/diamondmap Diamond tile shapes
982
+ */
983
+ tileShape: 'hexagon'
984
+
985
+ /**
986
+ * The column size - how many X axis units each column in the tilemap
987
+ * should span. Works as in [Heatmaps](#plotOptions.heatmap.colsize).
988
+ *
989
+ * @type {Number}
990
+ * @sample {highcharts} maps/demo/heatmap/ One day
991
+ * @sample {highmaps} maps/demo/heatmap/ One day
992
+ * @default 1
993
+ * @product highcharts highmaps
994
+ * @apioption plotOptions.tilemap.colsize
995
+ */
996
+
997
+ /**
998
+ * The row size - how many Y axis units each tilemap row should span.
999
+ * Analogous to [colsize](#plotOptions.tilemap.colsize).
1000
+ *
1001
+ * @type {Number}
1002
+ * @sample {highcharts} maps/demo/heatmap/ 1 by default
1003
+ * @sample {highmaps} maps/demo/heatmap/ 1 by default
1004
+ * @default 1
1005
+ * @product highcharts highmaps
1006
+ * @apioption plotOptions.tilemap.rowsize
1007
+ */
1008
+
1009
+ // Prototype functions
1010
+ }, {
1011
+
1012
+ // Set tile shape object on series
1013
+ setOptions: function() {
1014
+ // Call original function
1015
+ var ret = H.seriesTypes.heatmap.prototype.setOptions.apply(this,
1016
+ Array.prototype.slice.call(arguments)
1017
+ );
1018
+
1019
+ this.tileShape = H.tileShapeTypes[ret.tileShape];
1020
+ return ret;
1021
+ },
1022
+
1023
+ // Use the shape's defined data label alignment function
1024
+ alignDataLabel: function() {
1025
+ return this.tileShape.alignDataLabel.apply(this,
1026
+ Array.prototype.slice.call(arguments)
1027
+ );
1028
+ },
1029
+
1030
+ // Get metrics for padding of axis for this series
1031
+ getSeriesPixelPadding: function(axis) {
1032
+ var isX = axis.isXAxis,
1033
+ padding = this.tileShape.getSeriesPadding(this),
1034
+ coord1,
1035
+ coord2;
1036
+
1037
+ // If the shape type does not require padding, return no-op padding
1038
+ if (!padding) {
1039
+ return {
1040
+ padding: 0,
1041
+ axisLengthFactor: 1
1042
+ };
1043
+ }
1044
+
1045
+ // Use translate to compute how far outside the points we
1046
+ // draw, and use this difference as padding.
1047
+ coord1 = Math.round(
1048
+ axis.translate(
1049
+ isX ?
1050
+ padding.xPad * 2 :
1051
+ padding.yPad,
1052
+ 0, 1, 0, 1
1053
+ )
1054
+ );
1055
+ coord2 = Math.round(
1056
+ axis.translate(
1057
+ isX ? padding.xPad : 0,
1058
+ 0, 1, 0, 1
1059
+ )
1060
+ );
1061
+
1062
+ return {
1063
+ padding: Math.abs(coord1 - coord2) || 0,
1064
+
1065
+ // Offset the yAxis length to compensate for shift.
1066
+ // Setting the length factor to 2 would add the same margin to max
1067
+ // as min. Now we only add a slight bit of the min margin to max, as
1068
+ // we don't actually draw outside the max bounds. For the xAxis we
1069
+ // draw outside on both sides so we add the same margin to min and
1070
+ // max.
1071
+ axisLengthFactor: isX ? 2 : 1.1
1072
+ };
1073
+ },
1074
+
1075
+ // Use translate from tileShape
1076
+ translate: function() {
1077
+ return this.tileShape.translate.apply(this,
1078
+ Array.prototype.slice.call(arguments)
1079
+ );
1080
+ }
1081
+
1082
+ }, H.extend({
1083
+ haloPath: function() {
1084
+ return this.series.tileShape.haloPath.apply(this,
1085
+ Array.prototype.slice.call(arguments)
1086
+ );
1087
+ }
1088
+ }, H.colorPointMixin));
1089
+
1090
+ /**
1091
+ * A `tilemap` series. If the [type](#series.tilemap.type) option is
1092
+ * not specified, it is inherited from [chart.type](#chart.type).
1093
+ *
1094
+ * For options that apply to multiple series, it is recommended to add
1095
+ * them to the [plotOptions.series](#plotOptions.series) options structure.
1096
+ * To apply to all series of this specific type, apply it to [plotOptions.
1097
+ * tilemap](#plotOptions.tilemap).
1098
+ *
1099
+ * @type {Object}
1100
+ * @extends series,plotOptions.tilemap
1101
+ * @excluding joinBy, shadow, allAreas, mapData
1102
+ * @product highcharts highmaps
1103
+ * @apioption series.tilemap
1104
+ */
1105
+
1106
+ /**
1107
+ * An array of data points for the series. For the `tilemap` series
1108
+ * type, points can be given in the following ways:
1109
+ *
1110
+ * 1. An array of arrays with 3 or 2 values. In this case, the values
1111
+ * correspond to `x,y,value`. If the first value is a string, it is
1112
+ * applied as the name of the point, and the `x` value is inferred.
1113
+ * The `x` value can also be omitted, in which case the inner arrays
1114
+ * should be of length 2\. Then the `x` value is automatically calculated,
1115
+ * either starting at 0 and incremented by 1, or from `pointStart`
1116
+ * and `pointInterval` given in the series options.
1117
+ *
1118
+ * ```js
1119
+ * data: [
1120
+ * [0, 9, 7],
1121
+ * [1, 10, 4],
1122
+ * [2, 6, 3]
1123
+ * ]
1124
+ * ```
1125
+ *
1126
+ * 2. An array of objects with named values. The objects are point
1127
+ * configuration objects as seen below. If the total number of data
1128
+ * points exceeds the series' [turboThreshold](#series.tilemap.turboThreshold),
1129
+ * this option is not available.
1130
+ *
1131
+ * ```js
1132
+ * data: [{
1133
+ * x: 1,
1134
+ * y: 3,
1135
+ * value: 10,
1136
+ * name: "Point2",
1137
+ * color: "#00FF00"
1138
+ * }, {
1139
+ * x: 1,
1140
+ * y: 7,
1141
+ * value: 10,
1142
+ * name: "Point1",
1143
+ * color: "#FF00FF"
1144
+ * }]
1145
+ * ```
1146
+ *
1147
+ * Note that for some [tileShapes](#plotOptions.tilemap.tileShape) the grid
1148
+ * coordinates are offset.
1149
+ *
1150
+ * @type {Array<Object|Array>}
1151
+ * @extends series.heatmap.data
1152
+ * @excluding marker
1153
+ * @sample maps/series/tilemap-gridoffset Offset grid coordinates
1154
+ * @sample {highcharts} highcharts/chart/reflow-true/ Numerical values
1155
+ * @sample {highcharts} highcharts/series/data-array-of-arrays/ Arrays of numeric x and y
1156
+ * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/ Arrays of datetime x and y
1157
+ * @sample {highcharts} highcharts/series/data-array-of-name-value/ Arrays of point.name and y
1158
+ * @sample {highcharts} highcharts/series/data-array-of-objects/ Config objects
1159
+ * @product highcharts highmaps
1160
+ * @apioption series.tilemap.data
1161
+ */
1162
+
1163
+ /**
1164
+ * The color of the point. In tilemaps the point color is rarely set
1165
+ * explicitly, as we use the color to denote the `value`. Options for
1166
+ * this are set in the [colorAxis](#colorAxis) configuration.
1167
+ *
1168
+ * @type {Color}
1169
+ * @product highcharts highmaps
1170
+ * @apioption plotOptions.tilemap.data.color
1171
+ */
1172
+
1173
+ /**
1174
+ * The x coordinate of the point.
1175
+ *
1176
+ * Note that for some [tileShapes](#plotOptions.tilemap.tileShape) the grid
1177
+ * coordinates are offset.
1178
+ *
1179
+ * @type {Number}
1180
+ * @product highcharts highmaps
1181
+ * @sample maps/series/tilemap-gridoffset Offset grid coordinates
1182
+ * @apioption plotOptions.tilemap.data.x
1183
+ */
1184
+
1185
+ /**
1186
+ * The y coordinate of the point.
1187
+ *
1188
+ * Note that for some [tileShapes](#plotOptions.tilemap.tileShape) the grid
1189
+ * coordinates are offset.
1190
+ *
1191
+ * @type {Number}
1192
+ * @default undefined
1193
+ * @product highcharts highmaps
1194
+ * @sample maps/series/tilemap-gridoffset Offset grid coordinates
1195
+ * @apioption plotOptions.tilemap.data.y
1196
+ */
1197
+
1198
+ }(Highcharts));
1199
+ }));