highcharts-rails 4.2.3 → 4.2.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
  // @compilation_level SIMPLE_OPTIMIZATIONS
3
3
 
4
4
  /**
5
- * @license Highcharts JS v4.2.3 (2016-02-08)
5
+ * @license Highcharts JS v4.2.4 (2016-04-14)
6
6
  *
7
7
  * 3D features for Highcharts JS
8
8
  *
@@ -19,7 +19,8 @@
19
19
  /**
20
20
  Shorthands for often used function
21
21
  */
22
- var each = Highcharts.each,
22
+ var animObject = Highcharts.animObject,
23
+ each = Highcharts.each,
23
24
  extend = Highcharts.extend,
24
25
  inArray = Highcharts.inArray,
25
26
  merge = Highcharts.merge,
@@ -46,7 +47,8 @@
46
47
  function perspective(points, chart, insidePlotArea) {
47
48
  var options3d = chart.options.chart.options3d,
48
49
  inverted = false,
49
- origin;
50
+ origin,
51
+ scale = chart.scale3d || 1;
50
52
 
51
53
  if (insidePlotArea) {
52
54
  inverted = chart.inverted;
@@ -115,10 +117,12 @@
115
117
  py = py * (vd / (pz + ze + vd));
116
118
  }
117
119
 
120
+
118
121
  //Apply translation
119
- px = px + xe;
120
- py = py + ye;
121
- pz = pz + ze;
122
+ px = px * scale + xe;
123
+ py = py * scale + ye;
124
+ pz = pz * scale + ze;
125
+
122
126
 
123
127
  result.push({
124
128
  x: (inverted ? py : px),
@@ -486,13 +490,9 @@
486
490
  delete params.alpha;
487
491
  delete params.beta;
488
492
 
489
- animation = pick(animation, this.renderer.globalAnimation);
493
+ animation = animObject(pick(animation, this.renderer.globalAnimation));
490
494
 
491
- if (animation) {
492
- if (typeof animation !== 'object') {
493
- animation = {};
494
- }
495
-
495
+ if (animation.duration) {
496
496
  params = merge(params); // Don't mutate the original object
497
497
  ca = suckOutCustom(params);
498
498
 
@@ -725,6 +725,106 @@
725
725
  return this.options.chart.options3d && this.options.chart.options3d.enabled; // #4280
726
726
  };
727
727
 
728
+ /**
729
+ * Extend the getMargins method to calculate scale of the 3D view. That is required to
730
+ * fit chart's 3D projection into the actual plotting area. Reported as #4933.
731
+ */
732
+ Highcharts.wrap(Highcharts.Chart.prototype, 'getMargins', function (proceed) {
733
+ var chart = this,
734
+ options3d = chart.options.chart.options3d,
735
+ bbox3d = {
736
+ minX: Number.MAX_VALUE,
737
+ maxX: -Number.MAX_VALUE,
738
+ minY: Number.MAX_VALUE,
739
+ maxY: -Number.MAX_VALUE
740
+ },
741
+ plotLeft = chart.plotLeft,
742
+ plotRight = chart.plotWidth + plotLeft,
743
+ plotTop = chart.plotTop,
744
+ plotBottom = chart.plotHeight + plotTop,
745
+ originX = plotLeft + chart.plotWidth / 2,
746
+ originY = plotTop + chart.plotHeight / 2,
747
+ scale = 1,
748
+ corners = [],
749
+ i;
750
+
751
+ proceed.apply(this, [].slice.call(arguments, 1));
752
+
753
+ if (this.is3d()) {
754
+ if (options3d.fitToPlot === true) {
755
+ // Clear previous scale in case of updates:
756
+ chart.scale3d = 1;
757
+
758
+ // Top left corners:
759
+ corners = [{
760
+ x: plotLeft,
761
+ y: plotTop,
762
+ z: 0
763
+ }, {
764
+ x: plotLeft,
765
+ y: plotTop,
766
+ z: options3d.depth
767
+ }];
768
+
769
+ // Top right corners:
770
+ for (i = 0; i < 2; i++) {
771
+ corners.push({
772
+ x: plotRight,
773
+ y: corners[i].y,
774
+ z: corners[i].z
775
+ });
776
+ }
777
+
778
+ // All bottom corners:
779
+ for (i = 0; i < 4; i++) {
780
+ corners.push({
781
+ x: corners[i].x,
782
+ y: plotBottom,
783
+ z: corners[i].z
784
+ });
785
+ }
786
+
787
+ // Calculate 3D corners:
788
+ corners = perspective(corners, chart, false);
789
+
790
+ // Get bounding box of 3D element:
791
+ each(corners, function (corner) {
792
+ bbox3d.minX = Math.min(bbox3d.minX, corner.x);
793
+ bbox3d.maxX = Math.max(bbox3d.maxX, corner.x);
794
+ bbox3d.minY = Math.min(bbox3d.minY, corner.y);
795
+ bbox3d.maxY = Math.max(bbox3d.maxY, corner.y);
796
+ });
797
+
798
+ // Left edge:
799
+ if (plotLeft > bbox3d.minX) {
800
+ scale = Math.min(scale, 1 - Math.abs((plotLeft + originX) / (bbox3d.minX + originX)) % 1);
801
+ }
802
+
803
+ // Right edge:
804
+ if (plotRight < bbox3d.maxX) {
805
+ scale = Math.min(scale, (plotRight - originX) / (bbox3d.maxX - originX));
806
+ }
807
+
808
+ // Top edge:
809
+ if (plotTop > bbox3d.minY) {
810
+ if (bbox3d.minY < 0) {
811
+ scale = Math.min(scale, (plotTop + originY) / (-bbox3d.minY + plotTop + originY));
812
+ } else {
813
+ scale = Math.min(scale, 1 - (plotTop + originY) / (bbox3d.minY + originY) % 1);
814
+ }
815
+ }
816
+
817
+ // Bottom edge:
818
+ if (plotBottom < bbox3d.maxY) {
819
+ scale = Math.min(scale, Math.abs((plotBottom - originY) / (bbox3d.maxY - originY)));
820
+ }
821
+
822
+ // Set scale, used later in perspective method():
823
+ chart.scale3d = scale;
824
+ }
825
+ }
826
+ });
827
+
728
828
  Highcharts.wrap(Highcharts.Chart.prototype, 'isInsidePlot', function (proceed) {
729
829
  return this.is3d() || proceed.apply(this, [].slice.call(arguments, 1));
730
830
  });
@@ -735,6 +835,7 @@
735
835
  alpha: 0,
736
836
  beta: 0,
737
837
  depth: 100,
838
+ fitToPlot: true,
738
839
  viewDistance: 25,
739
840
  frame: {
740
841
  bottom: { size: 1, color: 'rgba(255,255,255,0)' },
@@ -1213,7 +1314,7 @@
1213
1314
  shapeArgs.insidePlotArea = true;
1214
1315
 
1215
1316
  // Translate the tooltip position in 3d space
1216
- tooltipPos = perspective([{ x: tooltipPos[0], y: tooltipPos[1], z: z }], chart, false)[0];
1317
+ tooltipPos = perspective([{ x: tooltipPos[0], y: tooltipPos[1], z: z }], chart, true)[0];
1217
1318
  point.tooltipPos = [tooltipPos.x, tooltipPos.y];
1218
1319
  }
1219
1320
  });
@@ -1495,7 +1596,7 @@
1495
1596
  // #4584 Check if has graphic - null points don't have it
1496
1597
  if (graphic) {
1497
1598
  // Hide null or 0 points (#3006, 3650)
1498
- graphic[point.y ? 'show' : 'hide']();
1599
+ graphic[point.y && point.visible ? 'show' : 'hide']();
1499
1600
  }
1500
1601
  });
1501
1602
  }
@@ -1653,6 +1754,10 @@
1653
1754
  this.axisTypes = ['xAxis', 'yAxis', 'zAxis'];
1654
1755
  this.pointArrayMap = ['x', 'y', 'z'];
1655
1756
  this.parallelArrays = ['x', 'y', 'z'];
1757
+
1758
+ // Require direct touch rather than using the k-d-tree, because the k-d-tree currently doesn't
1759
+ // take the xyz coordinate system into account (#4552)
1760
+ this.directTouch = true;
1656
1761
  }
1657
1762
 
1658
1763
  var result = proceed.apply(this, [chart, options]);
@@ -2,7 +2,7 @@
2
2
  // @compilation_level SIMPLE_OPTIMIZATIONS
3
3
 
4
4
  /**
5
- * @license Highcharts JS v4.2.3 (2016-02-08)
5
+ * @license Highcharts JS v4.2.4 (2016-04-14)
6
6
  *
7
7
  * (c) 2009-2016 Torstein Honsi
8
8
  *
@@ -24,6 +24,7 @@ var arrayMin = Highcharts.arrayMin,
24
24
  map = Highcharts.map,
25
25
  pick = Highcharts.pick,
26
26
  pInt = Highcharts.pInt,
27
+ correctFloat = Highcharts.correctFloat,
27
28
  defaultPlotOptions = Highcharts.getOptions().plotOptions,
28
29
  seriesTypes = Highcharts.seriesTypes,
29
30
  extendClass = Highcharts.extendClass,
@@ -971,7 +972,10 @@ var arrayMin = Highcharts.arrayMin,
971
972
  var series = this,
972
973
  yAxis = series.yAxis,
973
974
  xAxis = series.xAxis,
975
+ startAngleRad = xAxis.startAngleRad,
976
+ start,
974
977
  chart = series.chart,
978
+ isRadial = series.xAxis.isRadial,
975
979
  plotHigh;
976
980
 
977
981
  colProto.translate.apply(series);
@@ -989,7 +993,7 @@ var arrayMin = Highcharts.arrayMin,
989
993
 
990
994
  // adjust shape
991
995
  y = plotHigh;
992
- height = point.plotY - plotHigh;
996
+ height = pick(point.rectPlotY, point.plotY) - plotHigh;
993
997
 
994
998
  // Adjust for minPointLength
995
999
  if (Math.abs(height) < minPointLength) {
@@ -1003,19 +1007,28 @@ var arrayMin = Highcharts.arrayMin,
1003
1007
  y -= height;
1004
1008
  }
1005
1009
 
1006
- shapeArgs.height = height;
1007
- shapeArgs.y = y;
1008
-
1009
- point.tooltipPos = chart.inverted ?
1010
- [
1011
- yAxis.len + yAxis.pos - chart.plotLeft - y - height / 2,
1012
- xAxis.len + xAxis.pos - chart.plotTop - shapeArgs.x - shapeArgs.width / 2,
1013
- height
1014
- ] : [
1015
- xAxis.left - chart.plotLeft + shapeArgs.x + shapeArgs.width / 2,
1016
- yAxis.pos - chart.plotTop + y + height / 2,
1017
- height
1018
- ]; // don't inherit from column tooltip position - #3372
1010
+ if (isRadial) {
1011
+
1012
+ start = point.barX + startAngleRad;
1013
+ point.shapeType = 'path';
1014
+ point.shapeArgs = {
1015
+ d: series.polarArc(y + height, y, start, start + point.pointWidth)
1016
+ };
1017
+ } else {
1018
+ shapeArgs.height = height;
1019
+ shapeArgs.y = y;
1020
+
1021
+ point.tooltipPos = chart.inverted ?
1022
+ [
1023
+ yAxis.len + yAxis.pos - chart.plotLeft - y - height / 2,
1024
+ xAxis.len + xAxis.pos - chart.plotTop - shapeArgs.x - shapeArgs.width / 2,
1025
+ height
1026
+ ] : [
1027
+ xAxis.left - chart.plotLeft + shapeArgs.x + shapeArgs.width / 2,
1028
+ yAxis.pos - chart.plotTop + y + height / 2,
1029
+ height
1030
+ ]; // don't inherit from column tooltip position - #3372
1031
+ }
1019
1032
  });
1020
1033
  },
1021
1034
  directTouch: true,
@@ -1025,8 +1038,13 @@ var arrayMin = Highcharts.arrayMin,
1025
1038
  pointAttrToOptions: colProto.pointAttrToOptions,
1026
1039
  drawPoints: colProto.drawPoints,
1027
1040
  drawTracker: colProto.drawTracker,
1028
- animate: colProto.animate,
1029
- getColumnMetrics: colProto.getColumnMetrics
1041
+ getColumnMetrics: colProto.getColumnMetrics,
1042
+ animate: function () {
1043
+ return colProto.animate.apply(this, arguments);
1044
+ },
1045
+ polarArc: function () {
1046
+ return colProto.polarArc.apply(this, arguments);
1047
+ }
1030
1048
  });
1031
1049
  }());
1032
1050
 
@@ -1096,6 +1114,7 @@ var arrayMin = Highcharts.arrayMin,
1096
1114
  // chart.angular will be set to true when a gauge series is present, and this will
1097
1115
  // be used on the axes
1098
1116
  angular: true,
1117
+ directTouch: true, // #5063
1099
1118
  drawGraph: noop,
1100
1119
  fixedBox: true,
1101
1120
  forceDL: true,
@@ -1658,9 +1677,9 @@ var arrayMin = Highcharts.arrayMin,
1658
1677
  // override point value for sums
1659
1678
  // #3710 Update point does not propagate to sum
1660
1679
  if (point.isSum) {
1661
- point.y = yValue;
1680
+ point.y = correctFloat(yValue);
1662
1681
  } else if (point.isIntermediateSum) {
1663
- point.y = yValue - previousIntermediate; // #3840
1682
+ point.y = correctFloat(yValue - previousIntermediate); // #3840
1664
1683
  }
1665
1684
  // up points
1666
1685
  y = mathMax(previousY, previousY + point.y) + range[0];
@@ -1740,9 +1759,9 @@ var arrayMin = Highcharts.arrayMin,
1740
1759
  point = points && points[i] ? points[i] : {};
1741
1760
 
1742
1761
  if (y === 'sum' || point.isSum) {
1743
- yData[i] = sum;
1762
+ yData[i] = correctFloat(sum);
1744
1763
  } else if (y === 'intermediateSum' || point.isIntermediateSum) {
1745
- yData[i] = subSum;
1764
+ yData[i] = correctFloat(subSum);
1746
1765
  } else {
1747
1766
  sum += y;
1748
1767
  subSum += y;
@@ -2194,7 +2213,7 @@ var arrayMin = Highcharts.arrayMin,
2194
2213
 
2195
2214
  if (range > 0) {
2196
2215
  while (i--) {
2197
- if (typeof data[i] === 'number') {
2216
+ if (typeof data[i] === 'number' && axis.dataMin <= data[i] && data[i] <= axis.dataMax) {
2198
2217
  radius = series.radii[i];
2199
2218
  pxMin = Math.min(((data[i] - min) * transA) - radius, pxMin);
2200
2219
  pxMax = Math.max(((data[i] - min) * transA) + radius, pxMax);
@@ -2529,6 +2548,24 @@ var arrayMin = Highcharts.arrayMin,
2529
2548
  if (seriesTypes.column) {
2530
2549
 
2531
2550
  colProto = seriesTypes.column.prototype;
2551
+
2552
+ colProto.polarArc = function (low, high, start, end) {
2553
+ var center = this.xAxis.center,
2554
+ len = this.yAxis.len;
2555
+
2556
+ return this.chart.renderer.symbols.arc(
2557
+ center[0],
2558
+ center[1],
2559
+ len - high,
2560
+ null,
2561
+ {
2562
+ start: start,
2563
+ end: end,
2564
+ innerR: len - pick(low, len)
2565
+ }
2566
+ );
2567
+ };
2568
+
2532
2569
  /**
2533
2570
  * Define the animate method for columnseries
2534
2571
  */
@@ -2541,10 +2578,7 @@ var arrayMin = Highcharts.arrayMin,
2541
2578
  wrap(colProto, 'translate', function (proceed) {
2542
2579
 
2543
2580
  var xAxis = this.xAxis,
2544
- len = this.yAxis.len,
2545
- center = xAxis.center,
2546
2581
  startAngleRad = xAxis.startAngleRad,
2547
- renderer = this.chart.renderer,
2548
2582
  start,
2549
2583
  points,
2550
2584
  point,
@@ -2563,23 +2597,11 @@ var arrayMin = Highcharts.arrayMin,
2563
2597
  point = points[i];
2564
2598
  start = point.barX + startAngleRad;
2565
2599
  point.shapeType = 'path';
2566
- point.shapeArgs = {
2567
- d: renderer.symbols.arc(
2568
- center[0],
2569
- center[1],
2570
- len - point.plotY,
2571
- null,
2572
- {
2573
- start: start,
2574
- end: start + point.pointWidth,
2575
- innerR: len - pick(point.yBottom, len)
2576
- }
2577
- )
2578
- };
2600
+ point.shapeArgs = this.polarArc(point.yBottom, point.plotY, start, start + point.pointWidth);
2579
2601
  // Provide correct plotX, plotY for tooltip
2580
2602
  this.toXY(point);
2581
2603
  point.tooltipPos = [point.plotX, point.plotY];
2582
- point.ttBelow = point.plotY > center[1];
2604
+ point.ttBelow = point.plotY > xAxis.center[1];
2583
2605
  }
2584
2606
  }
2585
2607
  });
@@ -11,7 +11,8 @@
11
11
  * - Column range.
12
12
  * - Heatmap.
13
13
  * - Treemap.
14
- * - Check how it works with Highstock and data grouping.
14
+ * - Check how it works with Highstock and data grouping. Currently it only works when navigator.adaptToUpdatedData
15
+ * is false. It is also recommended to set scrollbar.liveRedraw to false.
15
16
  * - Check inverted charts.
16
17
  * - Check reversed axes.
17
18
  * - Chart callback should be async after last series is drawn. (But not necessarily, we don't do
@@ -29,7 +30,8 @@
29
30
  *
30
31
  * Notes for boost mode
31
32
  * - Area lines are not drawn
32
- * - Point markers are not drawn
33
+ * - Point markers are not drawn on line-type series
34
+ * - Lines are not drawn on scatter charts
33
35
  * - Zones and negativeColor don't work
34
36
  * - Columns are always one pixel wide. Don't set the threshold too low.
35
37
  *
@@ -64,6 +66,7 @@
64
66
  extend = H.extend,
65
67
  addEvent = H.addEvent,
66
68
  fireEvent = H.fireEvent,
69
+ grep = H.grep,
67
70
  merge = H.merge,
68
71
  pick = H.pick,
69
72
  wrap = H.wrap,
@@ -160,7 +163,7 @@
160
163
 
161
164
  H.extend(Series.prototype, {
162
165
  pointRange: 0,
163
-
166
+ allowDG: false, // No data grouping, let boost handle large data
164
167
  hasExtremes: function (checkX) {
165
168
  var options = this.options,
166
169
  data = options.data,
@@ -222,8 +225,8 @@
222
225
  ctx.clearRect(0, 0, width, height);
223
226
  }
224
227
 
225
- this.canvas.setAttribute('width', width);
226
- this.canvas.setAttribute('height', height);
228
+ this.canvas.width = width;
229
+ this.canvas.height = height;
227
230
  this.image.attr({
228
231
  width: width,
229
232
  height: height
@@ -534,7 +537,6 @@
534
537
 
535
538
  // Rect is twice as fast as arc, should be used for small markers
536
539
  seriesTypes.scatter.prototype.cvsMarkerSquare = function (ctx, clientX, plotY, r) {
537
- ctx.moveTo(clientX, plotY);
538
540
  ctx.rect(clientX - r, plotY - r, r * 2, r * 2);
539
541
  };
540
542
  seriesTypes.scatter.prototype.fill = true;
@@ -583,6 +585,26 @@
583
585
  return point;
584
586
  };
585
587
 
588
+ /**
589
+ * Extend series.destroy to also remove the fake k-d-tree points (#5137). Normally
590
+ * this is handled by Series.destroy that calls Point.destroy, but the fake
591
+ * search points are not registered like that.
592
+ */
593
+ wrap(Series.prototype, 'destroy', function (proceed) {
594
+ var series = this,
595
+ chart = series.chart;
596
+ if (chart.hoverPoints) {
597
+ chart.hoverPoints = grep(chart.hoverPoints, function (point) {
598
+ return point.series === series;
599
+ });
600
+ }
601
+
602
+ if (chart.hoverPoint && chart.hoverPoint.series === series) {
603
+ chart.hoverPoint = null;
604
+ }
605
+ proceed.call(this);
606
+ });
607
+
586
608
  /**
587
609
  * Return a point instance from the k-d-tree
588
610
  */