highcharts-rails 5.0.10 → 5.0.11

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 (25) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.markdown +48 -0
  3. data/app/assets/javascripts/highcharts.js +2395 -1517
  4. data/app/assets/javascripts/highcharts/highcharts-3d.js +212 -116
  5. data/app/assets/javascripts/highcharts/highcharts-more.js +17 -11
  6. data/app/assets/javascripts/highcharts/modules/accessibility.js +29 -16
  7. data/app/assets/javascripts/highcharts/modules/annotations.js +3 -4
  8. data/app/assets/javascripts/highcharts/modules/boost.js +392 -356
  9. data/app/assets/javascripts/highcharts/modules/broken-axis.js +42 -17
  10. data/app/assets/javascripts/highcharts/modules/data.js +6 -6
  11. data/app/assets/javascripts/highcharts/modules/drilldown.js +54 -27
  12. data/app/assets/javascripts/highcharts/modules/exporting.js +125 -102
  13. data/app/assets/javascripts/highcharts/modules/funnel.js +17 -9
  14. data/app/assets/javascripts/highcharts/modules/grid-axis.js +1 -1
  15. data/app/assets/javascripts/highcharts/modules/heatmap.js +12 -2
  16. data/app/assets/javascripts/highcharts/modules/no-data-to-display.js +1 -1
  17. data/app/assets/javascripts/highcharts/modules/offline-exporting.js +12 -4
  18. data/app/assets/javascripts/highcharts/modules/overlapping-datalabels.js +1 -1
  19. data/app/assets/javascripts/highcharts/modules/series-label.js +1 -1
  20. data/app/assets/javascripts/highcharts/modules/solid-gauge.js +2 -2
  21. data/app/assets/javascripts/highcharts/modules/stock.js +182 -101
  22. data/app/assets/javascripts/highcharts/modules/treemap.js +4 -7
  23. data/app/assets/javascripts/highcharts/modules/xrange-series.js +1 -1
  24. data/lib/highcharts/version.rb +1 -1
  25. metadata +1 -1
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v5.0.10 (2017-03-31)
2
+ * @license Highcharts JS v5.0.11 (2017-05-04)
3
3
  *
4
4
  * 3D features for Highcharts JS
5
5
  *
@@ -181,15 +181,6 @@
181
181
  return area / 2;
182
182
  }
183
183
 
184
- function averageZ(vertexes) {
185
- var z = 0,
186
- i;
187
- for (i = 0; i < vertexes.length; i++) {
188
- z += vertexes[i].z;
189
- }
190
- return vertexes.length ? z / vertexes.length : 0;
191
- }
192
-
193
184
  /** Method to construct a curved path
194
185
  * Can 'wrap' around more then 180 degrees
195
186
  */
@@ -256,16 +247,13 @@
256
247
 
257
248
  // create the 3 sides
258
249
  result.front = this.path(paths[0]).attr({
259
- 'class': 'highcharts-3d-front',
260
- zIndex: paths[3]
261
- }).add(result);
250
+ 'class': 'highcharts-3d-front'
251
+ }).add(result); // Front, top and side are never overlapping in our case so it is redundant to set zIndex of every element.
262
252
  result.top = this.path(paths[1]).attr({
263
- 'class': 'highcharts-3d-top',
264
- zIndex: paths[4]
253
+ 'class': 'highcharts-3d-top'
265
254
  }).add(result);
266
255
  result.side = this.path(paths[2]).attr({
267
- 'class': 'highcharts-3d-side',
268
- zIndex: paths[5]
256
+ 'class': 'highcharts-3d-side'
269
257
  }).add(result);
270
258
 
271
259
  // apply the fill everywhere, the top a bit brighter, the side a bit darker
@@ -311,16 +299,13 @@
311
299
  var shapeArgs = args.shapeArgs || args;
312
300
  var paths = this.renderer.cuboidPath(shapeArgs);
313
301
  this.front.attr({
314
- d: paths[0],
315
- zIndex: paths[3]
302
+ d: paths[0]
316
303
  });
317
304
  this.top.attr({
318
- d: paths[1],
319
- zIndex: paths[4]
305
+ d: paths[1]
320
306
  });
321
307
  this.side.attr({
322
- d: paths[2],
323
- zIndex: paths[5]
308
+ d: paths[2]
324
309
  });
325
310
  } else {
326
311
  return H.SVGElement.prototype.attr.call(this, args); // getter returns value
@@ -332,23 +317,17 @@
332
317
  result.animate = function(args, duration, complete) {
333
318
  if (defined(args.x) && defined(args.y)) {
334
319
  var paths = this.renderer.cuboidPath(args);
335
- this.front.attr({
336
- zIndex: paths[3]
337
- }).animate({
320
+ this.front.animate({
338
321
  d: paths[0]
339
322
  }, duration, complete);
340
- this.top.attr({
341
- zIndex: paths[4]
342
- }).animate({
323
+ this.top.animate({
343
324
  d: paths[1]
344
325
  }, duration, complete);
345
- this.side.attr({
346
- zIndex: paths[5]
347
- }).animate({
326
+ this.side.animate({
348
327
  d: paths[2]
349
328
  }, duration, complete);
350
329
  this.attr({
351
- zIndex: -paths[6] // #4774
330
+ zIndex: -paths[3] // #4774
352
331
  });
353
332
  } else if (args.opacity) {
354
333
  this.front.animate(args, duration, complete);
@@ -371,7 +350,7 @@
371
350
 
372
351
  // Apply the Z index to the cuboid group
373
352
  result.attr({
374
- zIndex: -paths[6]
353
+ zIndex: -paths[3]
375
354
  });
376
355
 
377
356
  return result;
@@ -380,57 +359,72 @@
380
359
  /**
381
360
  * Generates a cuboid
382
361
  */
383
- SVGRenderer.prototype.cuboidPath = function(shapeArgs) {
362
+ H.SVGRenderer.prototype.cuboidPath = function(shapeArgs) {
384
363
  var x = shapeArgs.x,
385
364
  y = shapeArgs.y,
386
365
  z = shapeArgs.z,
387
366
  h = shapeArgs.height,
388
367
  w = shapeArgs.width,
389
368
  d = shapeArgs.depth,
390
- chart = charts[this.chartIndex];
369
+ chart = charts[this.chartIndex],
370
+ front,
371
+ back,
372
+ top,
373
+ bottom,
374
+ left,
375
+ right,
376
+ shape,
377
+ path1,
378
+ path2,
379
+ path3,
380
+ isFront,
381
+ isTop,
382
+ isRight,
383
+ options3d = chart.options.chart.options3d,
384
+ alpha = options3d.alpha,
385
+ // Priority for x axis is the biggest,
386
+ // because of x direction has biggest influence on zIndex
387
+ incrementX = 10000,
388
+ // y axis has the smallest priority in case of our charts
389
+ // (needs to be set because of stacking)
390
+ incrementY = 10,
391
+ incrementZ = 100,
392
+ zIndex = 0;
391
393
 
392
394
  // The 8 corners of the cube
393
395
  var pArr = [{
394
- x: x,
395
- y: y,
396
- z: z
397
- },
398
- {
399
- x: x + w,
400
- y: y,
401
- z: z
402
- },
403
- {
404
- x: x + w,
405
- y: y + h,
406
- z: z
407
- },
408
- {
409
- x: x,
410
- y: y + h,
411
- z: z
412
- },
413
- {
414
- x: x,
415
- y: y + h,
416
- z: z + d
417
- },
418
- {
419
- x: x + w,
420
- y: y + h,
421
- z: z + d
422
- },
423
- {
424
- x: x + w,
425
- y: y,
426
- z: z + d
427
- },
428
- {
429
- x: x,
430
- y: y,
431
- z: z + d
432
- }
433
- ];
396
+ x: x,
397
+ y: y,
398
+ z: z
399
+ }, {
400
+ x: x + w,
401
+ y: y,
402
+ z: z
403
+ }, {
404
+ x: x + w,
405
+ y: y + h,
406
+ z: z
407
+ }, {
408
+ x: x,
409
+ y: y + h,
410
+ z: z
411
+ }, {
412
+ x: x,
413
+ y: y + h,
414
+ z: z + d
415
+ }, {
416
+ x: x + w,
417
+ y: y + h,
418
+ z: z + d
419
+ }, {
420
+ x: x + w,
421
+ y: y,
422
+ z: z + d
423
+ }, {
424
+ x: x,
425
+ y: y,
426
+ z: z + d
427
+ }];
434
428
 
435
429
  // apply perspective
436
430
  pArr = perspective(pArr, chart, shapeArgs.insidePlotArea);
@@ -439,34 +433,81 @@
439
433
  function mapPath(i) {
440
434
  return pArr[i];
441
435
  }
436
+
437
+ /*
438
+ * First value - path with specific side
439
+ * Second value - added information about side for later calculations.
440
+ * Possible second values are 0 for path1, 1 for path2 and -1 for no path choosed.
441
+ */
442
442
  var pickShape = function(path1, path2) {
443
- var ret = [];
443
+ var ret = [
444
+ [], -1
445
+ ];
444
446
  path1 = map(path1, mapPath);
445
447
  path2 = map(path2, mapPath);
446
448
  if (shapeArea(path1) < 0) {
447
- ret = path1;
449
+ ret = [path1, 0];
448
450
  } else if (shapeArea(path2) < 0) {
449
- ret = path2;
451
+ ret = [path2, 1];
450
452
  }
451
453
  return ret;
452
454
  };
453
455
 
454
456
  // front or back
455
- var front = [3, 2, 1, 0];
456
- var back = [7, 6, 5, 4];
457
- var path1 = pickShape(front, back);
457
+ front = [3, 2, 1, 0];
458
+ back = [7, 6, 5, 4];
459
+ shape = pickShape(front, back);
460
+ path1 = shape[0];
461
+ isFront = shape[1];
462
+
458
463
 
459
464
  // top or bottom
460
- var top = [1, 6, 7, 0];
461
- var bottom = [4, 5, 2, 3];
462
- var path2 = pickShape(top, bottom);
465
+ top = [1, 6, 7, 0];
466
+ bottom = [4, 5, 2, 3];
467
+ shape = pickShape(top, bottom);
468
+ path2 = shape[0];
469
+ isTop = shape[1];
463
470
 
464
471
  // side
465
- var right = [1, 2, 5, 6];
466
- var left = [0, 7, 4, 3];
467
- var path3 = pickShape(right, left);
472
+ right = [1, 2, 5, 6];
473
+ left = [0, 7, 4, 3];
474
+ shape = pickShape(right, left);
475
+ path3 = shape[0];
476
+ isRight = shape[1];
477
+
478
+ /*
479
+ * New block used for calculating zIndex. It is basing on X, Y and Z position of specific columns.
480
+ * All zIndexes (for X, Y and Z values) are added to the final zIndex, where every value has different priority.
481
+ * The biggest priority is in X and Z directions, the lowest index is for stacked columns (Y direction and the same X and Z positions).
482
+ * Big differents between priorities is made because we need to ensure that even for big changes in Y and Z parameters
483
+ * all columns will be drawn correctly.
484
+ */
485
+
486
+ if (isRight === 1) {
487
+ zIndex += incrementX * (1000 - x);
488
+ } else if (!isRight) {
489
+ zIndex += incrementX * x;
490
+ }
491
+
492
+ zIndex += incrementY * (!isTop ||
493
+ (alpha >= 0 && alpha <= 180 || alpha < 360 && alpha > 357.5) ? // Numbers checked empirically
494
+ chart.plotHeight - y : 10 + y
495
+ );
496
+
497
+ if (isFront === 1) {
498
+ zIndex += incrementZ * (z);
499
+ } else if (!isFront) {
500
+ zIndex += incrementZ * (1000 - z);
501
+ }
468
502
 
469
- return [this.toLinePath(path1, true), this.toLinePath(path2, true), this.toLinePath(path3, true), averageZ(path1), averageZ(path2), averageZ(path3), averageZ(map(bottom, mapPath)) * 9e9]; // #4774
503
+ zIndex = -Math.round(zIndex);
504
+
505
+ return [
506
+ this.toLinePath(path1, true),
507
+ this.toLinePath(path2, true),
508
+ this.toLinePath(path3, true),
509
+ zIndex
510
+ ]; // #4774
470
511
  };
471
512
 
472
513
  ////// SECTORS //////
@@ -1338,7 +1379,7 @@
1338
1379
  var path = proceed.apply(this, [].slice.call(arguments, 1));
1339
1380
 
1340
1381
  // Do not do this if the chart is not 3D
1341
- if (!this.axis.chart.is3d() || this.coll === 'colorAxis') {
1382
+ if (!this.axis.chart.is3d() || this.axis.coll === 'colorAxis') {
1342
1383
  return path;
1343
1384
  }
1344
1385
 
@@ -1367,7 +1408,7 @@
1367
1408
  var pos = proceed.apply(this, [].slice.call(arguments, 1));
1368
1409
 
1369
1410
  // Do not do this if the chart is not 3D
1370
- if (this.axis.chart.is3d() && this.coll !== 'colorAxis') {
1411
+ if (this.axis.chart.is3d() && this.axis.coll !== 'colorAxis') {
1371
1412
  pos = perspective([this.axis.swapZ({
1372
1413
  x: pos.x,
1373
1414
  y: pos.y,
@@ -1538,8 +1579,10 @@
1538
1579
  pick = H.pick,
1539
1580
  Series = H.Series,
1540
1581
  seriesTypes = H.seriesTypes,
1582
+ inArray = H.inArray,
1541
1583
  svg = H.svg,
1542
1584
  wrap = H.wrap;
1585
+
1543
1586
  /***
1544
1587
  EXTENSION FOR 3D COLUMNS
1545
1588
  ***/
@@ -1554,9 +1597,17 @@
1554
1597
  var series = this,
1555
1598
  chart = series.chart,
1556
1599
  seriesOptions = series.options,
1557
- depth = seriesOptions.depth || 25;
1600
+ depth = seriesOptions.depth || 25,
1601
+ borderCrisp = series.borderWidth % 2 ? 0.5 : 0;
1602
+
1603
+ if (
1604
+ (chart.inverted && !series.yAxis.reversed) ||
1605
+ (!chart.inverted && series.yAxis.reversed)
1606
+ ) {
1607
+ borderCrisp *= -1;
1608
+ }
1558
1609
 
1559
- var stack = seriesOptions.stacking ? (seriesOptions.stack || 0) : series._i;
1610
+ var stack = seriesOptions.stacking ? (seriesOptions.stack || 0) : series.index; // #4743
1560
1611
  var z = stack * (depth + (seriesOptions.groupZPadding || 1));
1561
1612
 
1562
1613
  if (seriesOptions.grouping !== false) {
@@ -1564,11 +1615,37 @@
1564
1615
  }
1565
1616
 
1566
1617
  z += (seriesOptions.groupZPadding || 1);
1567
-
1568
1618
  each(series.data, function(point) {
1569
1619
  if (point.y !== null) {
1570
1620
  var shapeArgs = point.shapeArgs,
1571
- tooltipPos = point.tooltipPos;
1621
+ tooltipPos = point.tooltipPos,
1622
+ // Array for final shapeArgs calculation.
1623
+ // We are checking two dimensions (x and y).
1624
+ dimensions = [
1625
+ ['x', 'width'],
1626
+ ['y', 'height']
1627
+ ],
1628
+ borderlessBase; // crisped rects can have +/- 0.5 pixels offset
1629
+
1630
+ // #3131 We need to check if column shape arguments are inside plotArea.
1631
+ each(dimensions, function(d) {
1632
+ borderlessBase = shapeArgs[d[0]] - borderCrisp;
1633
+ if (
1634
+ borderlessBase + shapeArgs[d[1]] < 0 || // End column position is smaller than axis start.
1635
+ borderlessBase > series[d[0] + 'Axis'].len // Start column position is bigger than axis end.
1636
+ ) {
1637
+ for (var key in shapeArgs) { // Set args to 0 if column is outside the chart.
1638
+ shapeArgs[key] = 0;
1639
+ }
1640
+ }
1641
+ if (borderlessBase < 0) {
1642
+ shapeArgs[d[1]] += shapeArgs[d[0]];
1643
+ shapeArgs[d[0]] = 0;
1644
+ }
1645
+ if (borderlessBase + shapeArgs[d[1]] > series[d[0] + 'Axis'].len) {
1646
+ shapeArgs[d[1]] = series[d[0] + 'Axis'].len - shapeArgs[d[0]];
1647
+ }
1648
+ });
1572
1649
 
1573
1650
  point.shapeType = 'cuboid';
1574
1651
  shapeArgs.z = z;
@@ -1637,6 +1714,44 @@
1637
1714
  }
1638
1715
  });
1639
1716
 
1717
+ /*
1718
+ * In case of 3d columns there is no sense to add this columns
1719
+ * to a specific series group - if series is added to a group
1720
+ * all columns will have the same zIndex in comparison with different series
1721
+ */
1722
+
1723
+ wrap(seriesTypes.column.prototype, 'plotGroup', function(proceed, prop, name, visibility, zIndex, parent) {
1724
+ if (this.chart.is3d() && parent && !this[prop]) {
1725
+ this[prop] = parent;
1726
+ parent.attr(this.getPlotBox());
1727
+ this[prop].survive = true;
1728
+ }
1729
+ return proceed.apply(this, Array.prototype.slice.call(arguments, 1));
1730
+ });
1731
+
1732
+ /*
1733
+ * When series is not added to group it is needed to change
1734
+ * setVisible method to allow correct Legend funcionality
1735
+ * This wrap is basing on pie chart series
1736
+ */
1737
+ wrap(seriesTypes.column.prototype, 'setVisible', function(proceed, vis) {
1738
+ var series = this,
1739
+ pointVis;
1740
+ if (series.chart.is3d()) {
1741
+ each(series.data, function(point) {
1742
+ point.visible = point.options.visible = vis = vis === undefined ? !point.visible : vis;
1743
+ pointVis = vis ? 'visible' : 'hidden';
1744
+ series.options.data[inArray(point, series.data)] = point.options;
1745
+ if (point.graphic) {
1746
+ point.graphic.attr({
1747
+ visibility: pointVis
1748
+ });
1749
+ }
1750
+ });
1751
+ }
1752
+ proceed.apply(this, Array.prototype.slice.call(arguments, 1));
1753
+ });
1754
+
1640
1755
  wrap(seriesTypes.column.prototype, 'init', function(proceed) {
1641
1756
  proceed.apply(this, [].slice.call(arguments, 1));
1642
1757
 
@@ -1684,24 +1799,11 @@
1684
1799
  wrap(seriesTypes.column.prototype, 'pointAttribs', pointAttribs);
1685
1800
  if (seriesTypes.columnrange) {
1686
1801
  wrap(seriesTypes.columnrange.prototype, 'pointAttribs', pointAttribs);
1802
+ seriesTypes.columnrange.prototype.plotGroup = seriesTypes.column.prototype.plotGroup;
1803
+ seriesTypes.columnrange.prototype.setVisible = seriesTypes.column.prototype.setVisible;
1687
1804
  }
1688
1805
 
1689
1806
 
1690
- function draw3DPoints(proceed) {
1691
- // Do not do this if the chart is not 3D
1692
- if (this.chart.is3d()) {
1693
- var grouping = this.chart.options.plotOptions.column.grouping;
1694
- if (grouping !== undefined && !grouping && this.group.zIndex !== undefined && !this.zIndexSet) {
1695
- this.group.attr({
1696
- zIndex: this.group.zIndex * 10
1697
- });
1698
- this.zIndexSet = true; // #4062 set zindex only once
1699
- }
1700
- }
1701
-
1702
- proceed.apply(this, [].slice.call(arguments, 1));
1703
- }
1704
-
1705
1807
  wrap(Series.prototype, 'alignDataLabel', function(proceed) {
1706
1808
 
1707
1809
  // Only do this for 3D columns and columnranges
@@ -1725,12 +1827,6 @@
1725
1827
  proceed.apply(this, [].slice.call(arguments, 1));
1726
1828
  });
1727
1829
 
1728
- if (seriesTypes.columnrange) {
1729
- wrap(seriesTypes.columnrange.prototype, 'drawPoints', draw3DPoints);
1730
- }
1731
-
1732
- wrap(seriesTypes.column.prototype, 'drawPoints', draw3DPoints);
1733
-
1734
1830
  /***
1735
1831
  EXTENSION FOR 3D CYLINDRICAL COLUMNS
1736
1832
  Not supported