highcharts-rails 3.0.7 → 3.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @license Highcharts JS v3.0.7 (2013-10-24)
2
+ * @license Highcharts JS v3.0.8 (2014-01-09)
3
3
  * MooTools adapter
4
4
  *
5
- * (c) 2010-2013 Torstein Hønsi
5
+ * (c) 2010-2014 Torstein Honsi
6
6
  *
7
7
  * License: www.highcharts.com/license
8
8
  */
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @license Highcharts JS v3.0.7 (2013-10-24)
2
+ * @license Highcharts JS v3.0.8 (2014-01-09)
3
3
  * Prototype adapter
4
4
  *
5
- * @author Michael Nelson, Torstein Hønsi.
5
+ * @author Michael Nelson, Torstein Honsi.
6
6
  *
7
7
  * Feel free to use and modify this script.
8
8
  * Highcharts license: www.highcharts.com/license.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v3.0.7 (2013-10-24)
2
+ * @license Highcharts JS v3.0.8 (2014-01-09)
3
3
  *
4
4
  * Standalone Highcharts Framework
5
5
  *
@@ -159,7 +159,15 @@ function augment(obj) {
159
159
 
160
160
  args.preventDefault = preventDefault;
161
161
  args.target = target;
162
- args.type = name; // #2297
162
+
163
+ // If the type is not set, we're running a custom event (#2297). If it is set,
164
+ // we're running a browser event, and setting it will cause en error in
165
+ // IE8 (#2465).
166
+ if (!args.type) {
167
+ args.type = name;
168
+ }
169
+
170
+
163
171
 
164
172
  // If the event handler return false, prevent the default handler from executing
165
173
  if (fn.call(this, args) === false) {
@@ -2,9 +2,9 @@
2
2
  // @compilation_level SIMPLE_OPTIMIZATIONS
3
3
 
4
4
  /**
5
- * @license Highcharts JS v3.0.7 (2013-10-24)
5
+ * @license Highcharts JS v3.0.8 (2014-01-09)
6
6
  *
7
- * (c) 2009-2013 Torstein Hønsi
7
+ * (c) 2009-2014 Torstein Honsi
8
8
  *
9
9
  * License: www.highcharts.com/license
10
10
  */
@@ -28,12 +28,16 @@ var arrayMin = Highcharts.arrayMin,
28
28
  wrap = Highcharts.wrap,
29
29
  Axis = Highcharts.Axis,
30
30
  Tick = Highcharts.Tick,
31
+ Point = Highcharts.Point,
32
+ Pointer = Highcharts.Pointer,
33
+ TrackerMixin = Highcharts.TrackerMixin,
34
+ CenteredSeriesMixin = Highcharts.CenteredSeriesMixin,
31
35
  Series = Highcharts.Series,
32
- colProto = seriesTypes.column.prototype,
33
36
  math = Math,
34
37
  mathRound = math.round,
35
38
  mathFloor = math.floor,
36
39
  mathMax = math.max,
40
+ Color = Highcharts.Color,
37
41
  noop = function () {};/**
38
42
  * The Pane object allows options that are common to a set of X and Y axes.
39
43
  *
@@ -217,6 +221,9 @@ var radialAxisMixin = {
217
221
 
218
222
  // Title or label offsets are not counted
219
223
  this.chart.axisOffset[this.side] = 0;
224
+
225
+ // Set the center array
226
+ this.center = this.pane.center = CenteredSeriesMixin.getCenter.call(this.pane);
220
227
  },
221
228
 
222
229
 
@@ -292,7 +299,7 @@ var radialAxisMixin = {
292
299
  if (this.isRadial) {
293
300
 
294
301
  // Set the center array
295
- this.center = this.pane.center = seriesTypes.pie.prototype.getCenter.call(this.pane);
302
+ this.center = this.pane.center = Highcharts.CenteredSeriesMixin.getCenter.call(this.pane);
296
303
 
297
304
  this.len = this.width = this.height = this.isCircular ?
298
305
  this.center[2] * (this.endAngleRad - this.startAngleRad) / 2 :
@@ -652,7 +659,7 @@ defaultPlotOptions.arearange = merge(defaultPlotOptions.area, {
652
659
  /**
653
660
  * Add the series type
654
661
  */
655
- seriesTypes.arearange = Highcharts.extendClass(seriesTypes.area, {
662
+ seriesTypes.arearange = extendClass(seriesTypes.area, {
656
663
  type: 'arearange',
657
664
  pointArrayMap: ['low', 'high'],
658
665
  toYData: function (point) {
@@ -801,7 +808,10 @@ seriesTypes.arearange = Highcharts.extendClass(seriesTypes.area, {
801
808
  dataLabelOptions.y = dataLabelOptions.yHigh;
802
809
  }
803
810
  }
804
- seriesProto.drawDataLabels.apply(this, arguments); // #1209
811
+
812
+ if (seriesProto.drawDataLabels) {
813
+ seriesProto.drawDataLabels.apply(this, arguments); // #1209
814
+ }
805
815
 
806
816
  // Step 2: reorganize and handle data labels for the lower values
807
817
  i = length;
@@ -825,12 +835,16 @@ seriesTypes.arearange = Highcharts.extendClass(seriesTypes.area, {
825
835
  dataLabelOptions.y = dataLabelOptions.yLow;
826
836
  }
827
837
  }
828
- seriesProto.drawDataLabels.apply(this, arguments);
838
+ if (seriesProto.drawDataLabels) {
839
+ seriesProto.drawDataLabels.apply(this, arguments);
840
+ }
829
841
  }
830
842
 
831
843
  },
832
844
 
833
- alignDataLabel: seriesTypes.column.prototype.alignDataLabel,
845
+ alignDataLabel: function () {
846
+ seriesTypes.column.prototype.alignDataLabel.apply(this, arguments);
847
+ },
834
848
 
835
849
  getSymbol: seriesTypes.column.prototype.getSymbol,
836
850
 
@@ -847,61 +861,69 @@ defaultPlotOptions.areasplinerange = merge(defaultPlotOptions.arearange);
847
861
  seriesTypes.areasplinerange = extendClass(seriesTypes.arearange, {
848
862
  type: 'areasplinerange',
849
863
  getPointSpline: seriesTypes.spline.prototype.getPointSpline
850
- });/**
851
- * The ColumnRangeSeries class
852
- */
853
- defaultPlotOptions.columnrange = merge(defaultPlotOptions.column, defaultPlotOptions.arearange, {
854
- lineWidth: 1,
855
- pointRange: null
856
864
  });
857
865
 
858
- /**
859
- * ColumnRangeSeries object
860
- */
861
- seriesTypes.columnrange = extendClass(seriesTypes.arearange, {
862
- type: 'columnrange',
866
+ (function () {
867
+
868
+ var colProto = seriesTypes.column.prototype;
869
+
863
870
  /**
864
- * Translate data points from raw values x and y to plotX and plotY
871
+ * The ColumnRangeSeries class
865
872
  */
866
- translate: function () {
867
- var series = this,
868
- yAxis = series.yAxis,
869
- plotHigh;
873
+ defaultPlotOptions.columnrange = merge(defaultPlotOptions.column, defaultPlotOptions.arearange, {
874
+ lineWidth: 1,
875
+ pointRange: null
876
+ });
870
877
 
871
- colProto.translate.apply(series);
878
+ /**
879
+ * ColumnRangeSeries object
880
+ */
881
+ seriesTypes.columnrange = extendClass(seriesTypes.arearange, {
882
+ type: 'columnrange',
883
+ /**
884
+ * Translate data points from raw values x and y to plotX and plotY
885
+ */
886
+ translate: function () {
887
+ var series = this,
888
+ yAxis = series.yAxis,
889
+ plotHigh;
890
+
891
+ colProto.translate.apply(series);
892
+
893
+ // Set plotLow and plotHigh
894
+ each(series.points, function (point) {
895
+ var shapeArgs = point.shapeArgs,
896
+ minPointLength = series.options.minPointLength,
897
+ heightDifference,
898
+ height,
899
+ y;
900
+
901
+ point.plotHigh = plotHigh = yAxis.translate(point.high, 0, 1, 0, 1);
902
+ point.plotLow = point.plotY;
903
+
904
+ // adjust shape
905
+ y = plotHigh;
906
+ height = point.plotY - plotHigh;
907
+
908
+ if (height < minPointLength) {
909
+ heightDifference = (minPointLength - height);
910
+ height += heightDifference;
911
+ y -= heightDifference / 2;
912
+ }
913
+ shapeArgs.height = height;
914
+ shapeArgs.y = y;
915
+ });
916
+ },
917
+ trackerGroups: ['group', 'dataLabels'],
918
+ drawGraph: noop,
919
+ pointAttrToOptions: colProto.pointAttrToOptions,
920
+ drawPoints: colProto.drawPoints,
921
+ drawTracker: colProto.drawTracker,
922
+ animate: colProto.animate,
923
+ getColumnMetrics: colProto.getColumnMetrics
924
+ });
925
+ }());
872
926
 
873
- // Set plotLow and plotHigh
874
- each(series.points, function (point) {
875
- var shapeArgs = point.shapeArgs,
876
- minPointLength = series.options.minPointLength,
877
- heightDifference,
878
- height,
879
- y;
880
-
881
- point.plotHigh = plotHigh = yAxis.translate(point.high, 0, 1, 0, 1);
882
- point.plotLow = point.plotY;
883
-
884
- // adjust shape
885
- y = plotHigh;
886
- height = point.plotY - plotHigh;
887
-
888
- if (height < minPointLength) {
889
- heightDifference = (minPointLength - height);
890
- height += heightDifference;
891
- y -= heightDifference / 2;
892
- }
893
- shapeArgs.height = height;
894
- shapeArgs.y = y;
895
- });
896
- },
897
- trackerGroups: ['group', 'dataLabels'],
898
- drawGraph: noop,
899
- pointAttrToOptions: colProto.pointAttrToOptions,
900
- drawPoints: colProto.drawPoints,
901
- drawTracker: colProto.drawTracker,
902
- animate: colProto.animate,
903
- getColumnMetrics: colProto.getColumnMetrics
904
- });
905
927
  /*
906
928
  * The GaugeSeries class
907
929
  */
@@ -918,6 +940,7 @@ defaultPlotOptions.gauge = merge(defaultPlotOptions.line, {
918
940
  borderWidth: 1,
919
941
  borderColor: 'silver',
920
942
  borderRadius: 3,
943
+ crop: false,
921
944
  style: {
922
945
  fontWeight: 'bold'
923
946
  },
@@ -949,7 +972,7 @@ defaultPlotOptions.gauge = merge(defaultPlotOptions.line, {
949
972
  /**
950
973
  * Extend the point object
951
974
  */
952
- var GaugePoint = Highcharts.extendClass(Highcharts.Point, {
975
+ var GaugePoint = extendClass(Point, {
953
976
  /**
954
977
  * Don't do any hover colors or anything
955
978
  */
@@ -971,6 +994,7 @@ var GaugeSeries = {
971
994
  angular: true,
972
995
  drawGraph: noop,
973
996
  fixedBox: true,
997
+ forceDL: true,
974
998
  trackerGroups: ['group', 'dataLabels'],
975
999
 
976
1000
  /**
@@ -1113,14 +1137,27 @@ var GaugeSeries = {
1113
1137
  this.options.zIndex,
1114
1138
  this.chart.seriesGroup
1115
1139
  );
1116
- seriesTypes.pie.prototype.render.call(this);
1140
+ Series.prototype.render.call(this);
1117
1141
  this.group.clip(this.chart.clipRect);
1118
1142
  },
1119
1143
 
1120
- setData: seriesTypes.pie.prototype.setData,
1121
- drawTracker: seriesTypes.column.prototype.drawTracker
1144
+ /**
1145
+ * Extend the basic setData method by running processData and generatePoints immediately,
1146
+ * in order to access the points from the legend.
1147
+ */
1148
+ setData: function (data, redraw) {
1149
+ Series.prototype.setData.call(this, data, false);
1150
+ this.processData();
1151
+ this.generatePoints();
1152
+ if (pick(redraw, true)) {
1153
+ this.chart.redraw();
1154
+ }
1155
+ },
1156
+ drawTracker: TrackerMixin.drawTrackerPoint
1122
1157
  };
1123
- seriesTypes.gauge = Highcharts.extendClass(seriesTypes.line, GaugeSeries);/* ****************************************************************************
1158
+ seriesTypes.gauge = extendClass(seriesTypes.line, GaugeSeries);
1159
+
1160
+ /* ****************************************************************************
1124
1161
  * Start Box plot series code *
1125
1162
  *****************************************************************************/
1126
1163
 
@@ -1403,7 +1440,7 @@ defaultPlotOptions.errorbar = merge(defaultPlotOptions.boxplot, {
1403
1440
  grouping: false,
1404
1441
  linkedTo: ':previous',
1405
1442
  tooltip: {
1406
- pointFormat: defaultPlotOptions.arearange.tooltip.pointFormat
1443
+ pointFormat: '<span style="color:{series.color}">{series.name}</span>: <b>{point.low}</b> - <b>{point.high}</b><br/>'
1407
1444
  },
1408
1445
  whiskerWidth: null
1409
1446
  });
@@ -1714,6 +1751,7 @@ defaultPlotOptions.bubble = merge(defaultPlotOptions.scatter, {
1714
1751
  seriesTypes.bubble = extendClass(seriesTypes.scatter, {
1715
1752
  type: 'bubble',
1716
1753
  pointArrayMap: ['y', 'z'],
1754
+ parallelArrays: ['x', 'y', 'z'],
1717
1755
  trackerGroups: ['group', 'dataLabelsGroup'],
1718
1756
  bubblePadding: true,
1719
1757
 
@@ -1737,7 +1775,7 @@ seriesTypes.bubble = extendClass(seriesTypes.scatter, {
1737
1775
  fill = fill || markerOptions.fillColor || this.color;
1738
1776
 
1739
1777
  if (fillOpacity !== 1) {
1740
- fill = Highcharts.Color(fill).setOpacity(fillOpacity).get('rgba');
1778
+ fill = Color(fill).setOpacity(fillOpacity).get('rgba');
1741
1779
  }
1742
1780
  return fill;
1743
1781
  },
@@ -1773,7 +1811,7 @@ seriesTypes.bubble = extendClass(seriesTypes.scatter, {
1773
1811
  pos = zRange > 0 ? // relative size, a number between 0 and 1
1774
1812
  (zData[i] - zMin) / (zMax - zMin) :
1775
1813
  0.5;
1776
- if (sizeByArea) {
1814
+ if (sizeByArea && pos >= 0) {
1777
1815
  pos = Math.sqrt(pos);
1778
1816
  }
1779
1817
  radii.push(math.ceil(minSize + pos * (maxSize - minSize)) / 2);
@@ -1957,7 +1995,7 @@ Axis.prototype.beforePadding = function () {
1957
1995
 
1958
1996
  if (range > 0) {
1959
1997
  while (i--) {
1960
- if (data[i] !== null) {
1998
+ if (typeof data[i] === 'number') {
1961
1999
  radius = series.radii[i];
1962
2000
  pxMin = Math.min(((data[i] - min) * transA) - radius, pxMin);
1963
2001
  pxMax = Math.max(((data[i] - min) * transA) + radius, pxMax);
@@ -1978,462 +2016,482 @@ Axis.prototype.beforePadding = function () {
1978
2016
  /* ****************************************************************************
1979
2017
  * End Bubble series code *
1980
2018
  *****************************************************************************/
1981
- /**
1982
- * Extensions for polar charts. Additionally, much of the geometry required for polar charts is
1983
- * gathered in RadialAxes.js.
1984
- *
1985
- */
1986
2019
 
1987
- var seriesProto = Series.prototype,
1988
- pointerProto = Highcharts.Pointer.prototype;
2020
+ (function () {
1989
2021
 
2022
+ /**
2023
+ * Extensions for polar charts. Additionally, much of the geometry required for polar charts is
2024
+ * gathered in RadialAxes.js.
2025
+ *
2026
+ */
1990
2027
 
2028
+ var seriesProto = Series.prototype,
2029
+ pointerProto = Pointer.prototype,
2030
+ colProto;
1991
2031
 
1992
- /**
1993
- * Translate a point's plotX and plotY from the internal angle and radius measures to
1994
- * true plotX, plotY coordinates
1995
- */
1996
- seriesProto.toXY = function (point) {
1997
- var xy,
1998
- chart = this.chart,
1999
- plotX = point.plotX,
2000
- plotY = point.plotY;
2032
+ /**
2033
+ * Translate a point's plotX and plotY from the internal angle and radius measures to
2034
+ * true plotX, plotY coordinates
2035
+ */
2036
+ seriesProto.toXY = function (point) {
2037
+ var xy,
2038
+ chart = this.chart,
2039
+ plotX = point.plotX,
2040
+ plotY = point.plotY;
2001
2041
 
2002
- // Save rectangular plotX, plotY for later computation
2003
- point.rectPlotX = plotX;
2004
- point.rectPlotY = plotY;
2042
+ // Save rectangular plotX, plotY for later computation
2043
+ point.rectPlotX = plotX;
2044
+ point.rectPlotY = plotY;
2005
2045
 
2006
- // Record the angle in degrees for use in tooltip
2007
- point.clientX = ((plotX / Math.PI * 180) + this.xAxis.pane.options.startAngle) % 360;
2046
+ // Record the angle in degrees for use in tooltip
2047
+ point.clientX = ((plotX / Math.PI * 180) + this.xAxis.pane.options.startAngle) % 360;
2008
2048
 
2009
- // Find the polar plotX and plotY
2010
- xy = this.xAxis.postTranslate(point.plotX, this.yAxis.len - plotY);
2011
- point.plotX = point.polarPlotX = xy.x - chart.plotLeft;
2012
- point.plotY = point.polarPlotY = xy.y - chart.plotTop;
2013
- };
2049
+ // Find the polar plotX and plotY
2050
+ xy = this.xAxis.postTranslate(point.plotX, this.yAxis.len - plotY);
2051
+ point.plotX = point.polarPlotX = xy.x - chart.plotLeft;
2052
+ point.plotY = point.polarPlotY = xy.y - chart.plotTop;
2053
+ };
2014
2054
 
2015
- /**
2016
- * Order the tooltip points to get the mouse capture ranges correct. #1915.
2017
- */
2018
- seriesProto.orderTooltipPoints = function (points) {
2019
- if (this.chart.polar) {
2020
- points.sort(function (a, b) {
2021
- return a.clientX - b.clientX;
2022
- });
2055
+ /**
2056
+ * Order the tooltip points to get the mouse capture ranges correct. #1915.
2057
+ */
2058
+ seriesProto.orderTooltipPoints = function (points) {
2059
+ if (this.chart.polar) {
2060
+ points.sort(function (a, b) {
2061
+ return a.clientX - b.clientX;
2062
+ });
2023
2063
 
2024
- // Wrap mouse tracking around to capture movement on the segment to the left
2025
- // of the north point (#1469, #2093).
2026
- if (points[0]) {
2027
- points[0].wrappedClientX = points[0].clientX + 360;
2028
- points.push(points[0]);
2064
+ // Wrap mouse tracking around to capture movement on the segment to the left
2065
+ // of the north point (#1469, #2093).
2066
+ if (points[0]) {
2067
+ points[0].wrappedClientX = points[0].clientX + 360;
2068
+ points.push(points[0]);
2069
+ }
2029
2070
  }
2030
- }
2031
- };
2071
+ };
2032
2072
 
2033
2073
 
2034
- /**
2035
- * Add some special init logic to areas and areasplines
2036
- */
2037
- function initArea(proceed, chart, options) {
2038
- proceed.call(this, chart, options);
2039
- if (this.chart.polar) {
2040
-
2041
- /**
2042
- * Overridden method to close a segment path. While in a cartesian plane the area
2043
- * goes down to the threshold, in the polar chart it goes to the center.
2044
- */
2045
- this.closeSegment = function (path) {
2046
- var center = this.xAxis.center;
2047
- path.push(
2048
- 'L',
2049
- center[0],
2050
- center[1]
2051
- );
2052
- };
2074
+ /**
2075
+ * Add some special init logic to areas and areasplines
2076
+ */
2077
+ function initArea(proceed, chart, options) {
2078
+ proceed.call(this, chart, options);
2079
+ if (this.chart.polar) {
2080
+
2081
+ /**
2082
+ * Overridden method to close a segment path. While in a cartesian plane the area
2083
+ * goes down to the threshold, in the polar chart it goes to the center.
2084
+ */
2085
+ this.closeSegment = function (path) {
2086
+ var center = this.xAxis.center;
2087
+ path.push(
2088
+ 'L',
2089
+ center[0],
2090
+ center[1]
2091
+ );
2092
+ };
2053
2093
 
2054
- // Instead of complicated logic to draw an area around the inner area in a stack,
2055
- // just draw it behind
2056
- this.closedStacks = true;
2094
+ // Instead of complicated logic to draw an area around the inner area in a stack,
2095
+ // just draw it behind
2096
+ this.closedStacks = true;
2097
+ }
2057
2098
  }
2058
- }
2059
- wrap(seriesTypes.area.prototype, 'init', initArea);
2060
- wrap(seriesTypes.areaspline.prototype, 'init', initArea);
2061
-
2062
2099
 
2063
- /**
2064
- * Overridden method for calculating a spline from one point to the next
2065
- */
2066
- wrap(seriesTypes.spline.prototype, 'getPointSpline', function (proceed, segment, point, i) {
2067
-
2068
- var ret,
2069
- smoothing = 1.5, // 1 means control points midway between points, 2 means 1/3 from the point, 3 is 1/4 etc;
2070
- denom = smoothing + 1,
2071
- plotX,
2072
- plotY,
2073
- lastPoint,
2074
- nextPoint,
2075
- lastX,
2076
- lastY,
2077
- nextX,
2078
- nextY,
2079
- leftContX,
2080
- leftContY,
2081
- rightContX,
2082
- rightContY,
2083
- distanceLeftControlPoint,
2084
- distanceRightControlPoint,
2085
- leftContAngle,
2086
- rightContAngle,
2087
- jointAngle;
2088
-
2089
-
2090
- if (this.chart.polar) {
2091
-
2092
- plotX = point.plotX;
2093
- plotY = point.plotY;
2094
- lastPoint = segment[i - 1];
2095
- nextPoint = segment[i + 1];
2100
+ if (seriesTypes.area) {
2101
+ wrap(seriesTypes.area.prototype, 'init', initArea);
2102
+ }
2103
+ if (seriesTypes.areaspline) {
2104
+ wrap(seriesTypes.areaspline.prototype, 'init', initArea);
2105
+ }
2106
+
2107
+ if (seriesTypes.spline) {
2108
+ /**
2109
+ * Overridden method for calculating a spline from one point to the next
2110
+ */
2111
+ wrap(seriesTypes.spline.prototype, 'getPointSpline', function (proceed, segment, point, i) {
2112
+
2113
+ var ret,
2114
+ smoothing = 1.5, // 1 means control points midway between points, 2 means 1/3 from the point, 3 is 1/4 etc;
2115
+ denom = smoothing + 1,
2116
+ plotX,
2117
+ plotY,
2118
+ lastPoint,
2119
+ nextPoint,
2120
+ lastX,
2121
+ lastY,
2122
+ nextX,
2123
+ nextY,
2124
+ leftContX,
2125
+ leftContY,
2126
+ rightContX,
2127
+ rightContY,
2128
+ distanceLeftControlPoint,
2129
+ distanceRightControlPoint,
2130
+ leftContAngle,
2131
+ rightContAngle,
2132
+ jointAngle;
2133
+
2134
+
2135
+ if (this.chart.polar) {
2136
+
2137
+ plotX = point.plotX;
2138
+ plotY = point.plotY;
2139
+ lastPoint = segment[i - 1];
2140
+ nextPoint = segment[i + 1];
2096
2141
 
2097
- // Connect ends
2098
- if (this.connectEnds) {
2099
- if (!lastPoint) {
2100
- lastPoint = segment[segment.length - 2]; // not the last but the second last, because the segment is already connected
2101
- }
2102
- if (!nextPoint) {
2103
- nextPoint = segment[1];
2104
- }
2105
- }
2142
+ // Connect ends
2143
+ if (this.connectEnds) {
2144
+ if (!lastPoint) {
2145
+ lastPoint = segment[segment.length - 2]; // not the last but the second last, because the segment is already connected
2146
+ }
2147
+ if (!nextPoint) {
2148
+ nextPoint = segment[1];
2149
+ }
2150
+ }
2106
2151
 
2107
- // find control points
2108
- if (lastPoint && nextPoint) {
2109
-
2110
- lastX = lastPoint.plotX;
2111
- lastY = lastPoint.plotY;
2112
- nextX = nextPoint.plotX;
2113
- nextY = nextPoint.plotY;
2114
- leftContX = (smoothing * plotX + lastX) / denom;
2115
- leftContY = (smoothing * plotY + lastY) / denom;
2116
- rightContX = (smoothing * plotX + nextX) / denom;
2117
- rightContY = (smoothing * plotY + nextY) / denom;
2118
- distanceLeftControlPoint = Math.sqrt(Math.pow(leftContX - plotX, 2) + Math.pow(leftContY - plotY, 2));
2119
- distanceRightControlPoint = Math.sqrt(Math.pow(rightContX - plotX, 2) + Math.pow(rightContY - plotY, 2));
2120
- leftContAngle = Math.atan2(leftContY - plotY, leftContX - plotX);
2121
- rightContAngle = Math.atan2(rightContY - plotY, rightContX - plotX);
2122
- jointAngle = (Math.PI / 2) + ((leftContAngle + rightContAngle) / 2);
2152
+ // find control points
2153
+ if (lastPoint && nextPoint) {
2154
+
2155
+ lastX = lastPoint.plotX;
2156
+ lastY = lastPoint.plotY;
2157
+ nextX = nextPoint.plotX;
2158
+ nextY = nextPoint.plotY;
2159
+ leftContX = (smoothing * plotX + lastX) / denom;
2160
+ leftContY = (smoothing * plotY + lastY) / denom;
2161
+ rightContX = (smoothing * plotX + nextX) / denom;
2162
+ rightContY = (smoothing * plotY + nextY) / denom;
2163
+ distanceLeftControlPoint = Math.sqrt(Math.pow(leftContX - plotX, 2) + Math.pow(leftContY - plotY, 2));
2164
+ distanceRightControlPoint = Math.sqrt(Math.pow(rightContX - plotX, 2) + Math.pow(rightContY - plotY, 2));
2165
+ leftContAngle = Math.atan2(leftContY - plotY, leftContX - plotX);
2166
+ rightContAngle = Math.atan2(rightContY - plotY, rightContX - plotX);
2167
+ jointAngle = (Math.PI / 2) + ((leftContAngle + rightContAngle) / 2);
2123
2168
 
2124
2169
 
2125
- // Ensure the right direction, jointAngle should be in the same quadrant as leftContAngle
2126
- if (Math.abs(leftContAngle - jointAngle) > Math.PI / 2) {
2127
- jointAngle -= Math.PI;
2128
- }
2170
+ // Ensure the right direction, jointAngle should be in the same quadrant as leftContAngle
2171
+ if (Math.abs(leftContAngle - jointAngle) > Math.PI / 2) {
2172
+ jointAngle -= Math.PI;
2173
+ }
2129
2174
 
2130
- // Find the corrected control points for a spline straight through the point
2131
- leftContX = plotX + Math.cos(jointAngle) * distanceLeftControlPoint;
2132
- leftContY = plotY + Math.sin(jointAngle) * distanceLeftControlPoint;
2133
- rightContX = plotX + Math.cos(Math.PI + jointAngle) * distanceRightControlPoint;
2134
- rightContY = plotY + Math.sin(Math.PI + jointAngle) * distanceRightControlPoint;
2175
+ // Find the corrected control points for a spline straight through the point
2176
+ leftContX = plotX + Math.cos(jointAngle) * distanceLeftControlPoint;
2177
+ leftContY = plotY + Math.sin(jointAngle) * distanceLeftControlPoint;
2178
+ rightContX = plotX + Math.cos(Math.PI + jointAngle) * distanceRightControlPoint;
2179
+ rightContY = plotY + Math.sin(Math.PI + jointAngle) * distanceRightControlPoint;
2135
2180
 
2136
- // Record for drawing in next point
2137
- point.rightContX = rightContX;
2138
- point.rightContY = rightContY;
2181
+ // Record for drawing in next point
2182
+ point.rightContX = rightContX;
2183
+ point.rightContY = rightContY;
2139
2184
 
2140
- }
2185
+ }
2141
2186
 
2142
2187
 
2143
- // moveTo or lineTo
2144
- if (!i) {
2145
- ret = ['M', plotX, plotY];
2146
- } else { // curve from last point to this
2147
- ret = [
2148
- 'C',
2149
- lastPoint.rightContX || lastPoint.plotX,
2150
- lastPoint.rightContY || lastPoint.plotY,
2151
- leftContX || plotX,
2152
- leftContY || plotY,
2153
- plotX,
2154
- plotY
2155
- ];
2156
- lastPoint.rightContX = lastPoint.rightContY = null; // reset for updating series later
2157
- }
2188
+ // moveTo or lineTo
2189
+ if (!i) {
2190
+ ret = ['M', plotX, plotY];
2191
+ } else { // curve from last point to this
2192
+ ret = [
2193
+ 'C',
2194
+ lastPoint.rightContX || lastPoint.plotX,
2195
+ lastPoint.rightContY || lastPoint.plotY,
2196
+ leftContX || plotX,
2197
+ leftContY || plotY,
2198
+ plotX,
2199
+ plotY
2200
+ ];
2201
+ lastPoint.rightContX = lastPoint.rightContY = null; // reset for updating series later
2202
+ }
2158
2203
 
2159
2204
 
2160
- } else {
2161
- ret = proceed.call(this, segment, point, i);
2205
+ } else {
2206
+ ret = proceed.call(this, segment, point, i);
2207
+ }
2208
+ return ret;
2209
+ });
2162
2210
  }
2163
- return ret;
2164
- });
2165
2211
 
2166
- /**
2167
- * Extend translate. The plotX and plotY values are computed as if the polar chart were a
2168
- * cartesian plane, where plotX denotes the angle in radians and (yAxis.len - plotY) is the pixel distance from
2169
- * center.
2170
- */
2171
- wrap(seriesProto, 'translate', function (proceed) {
2212
+ /**
2213
+ * Extend translate. The plotX and plotY values are computed as if the polar chart were a
2214
+ * cartesian plane, where plotX denotes the angle in radians and (yAxis.len - plotY) is the pixel distance from
2215
+ * center.
2216
+ */
2217
+ wrap(seriesProto, 'translate', function (proceed) {
2172
2218
 
2173
- // Run uber method
2174
- proceed.call(this);
2219
+ // Run uber method
2220
+ proceed.call(this);
2175
2221
 
2176
- // Postprocess plot coordinates
2177
- if (this.chart.polar && !this.preventPostTranslate) {
2178
- var points = this.points,
2179
- i = points.length;
2180
- while (i--) {
2181
- // Translate plotX, plotY from angle and radius to true plot coordinates
2182
- this.toXY(points[i]);
2222
+ // Postprocess plot coordinates
2223
+ if (this.chart.polar && !this.preventPostTranslate) {
2224
+ var points = this.points,
2225
+ i = points.length;
2226
+ while (i--) {
2227
+ // Translate plotX, plotY from angle and radius to true plot coordinates
2228
+ this.toXY(points[i]);
2229
+ }
2183
2230
  }
2184
- }
2185
- });
2231
+ });
2186
2232
 
2187
- /**
2188
- * Extend getSegmentPath to allow connecting ends across 0 to provide a closed circle in
2189
- * line-like series.
2190
- */
2191
- wrap(seriesProto, 'getSegmentPath', function (proceed, segment) {
2233
+ /**
2234
+ * Extend getSegmentPath to allow connecting ends across 0 to provide a closed circle in
2235
+ * line-like series.
2236
+ */
2237
+ wrap(seriesProto, 'getSegmentPath', function (proceed, segment) {
2192
2238
 
2193
- var points = this.points;
2239
+ var points = this.points;
2194
2240
 
2195
- // Connect the path
2196
- if (this.chart.polar && this.options.connectEnds !== false &&
2197
- segment[segment.length - 1] === points[points.length - 1] && points[0].y !== null) {
2198
- this.connectEnds = true; // re-used in splines
2199
- segment = [].concat(segment, [points[0]]);
2200
- }
2241
+ // Connect the path
2242
+ if (this.chart.polar && this.options.connectEnds !== false &&
2243
+ segment[segment.length - 1] === points[points.length - 1] && points[0].y !== null) {
2244
+ this.connectEnds = true; // re-used in splines
2245
+ segment = [].concat(segment, [points[0]]);
2246
+ }
2201
2247
 
2202
- // Run uber method
2203
- return proceed.call(this, segment);
2248
+ // Run uber method
2249
+ return proceed.call(this, segment);
2204
2250
 
2205
- });
2206
-
2251
+ });
2207
2252
 
2208
- function polarAnimate(proceed, init) {
2209
- var chart = this.chart,
2210
- animation = this.options.animation,
2211
- group = this.group,
2212
- markerGroup = this.markerGroup,
2213
- center = this.xAxis.center,
2214
- plotLeft = chart.plotLeft,
2215
- plotTop = chart.plotTop,
2216
- attribs;
2217
-
2218
- // Specific animation for polar charts
2219
- if (chart.polar) {
2220
-
2221
- // Enable animation on polar charts only in SVG. In VML, the scaling is different, plus animation
2222
- // would be so slow it would't matter.
2223
- if (chart.renderer.isSVG) {
2224
2253
 
2225
- if (animation === true) {
2226
- animation = {};
2227
- }
2254
+ function polarAnimate(proceed, init) {
2255
+ var chart = this.chart,
2256
+ animation = this.options.animation,
2257
+ group = this.group,
2258
+ markerGroup = this.markerGroup,
2259
+ center = this.xAxis.center,
2260
+ plotLeft = chart.plotLeft,
2261
+ plotTop = chart.plotTop,
2262
+ attribs;
2263
+
2264
+ // Specific animation for polar charts
2265
+ if (chart.polar) {
2266
+
2267
+ // Enable animation on polar charts only in SVG. In VML, the scaling is different, plus animation
2268
+ // would be so slow it would't matter.
2269
+ if (chart.renderer.isSVG) {
2270
+
2271
+ if (animation === true) {
2272
+ animation = {};
2273
+ }
2228
2274
 
2229
- // Initialize the animation
2230
- if (init) {
2275
+ // Initialize the animation
2276
+ if (init) {
2231
2277
 
2232
- // Scale down the group and place it in the center
2233
- attribs = {
2234
- translateX: center[0] + plotLeft,
2235
- translateY: center[1] + plotTop,
2236
- scaleX: 0.001, // #1499
2237
- scaleY: 0.001
2238
- };
2278
+ // Scale down the group and place it in the center
2279
+ attribs = {
2280
+ translateX: center[0] + plotLeft,
2281
+ translateY: center[1] + plotTop,
2282
+ scaleX: 0.001, // #1499
2283
+ scaleY: 0.001
2284
+ };
2239
2285
 
2240
- group.attr(attribs);
2241
- if (markerGroup) {
2242
- markerGroup.attrSetters = group.attrSetters;
2243
- markerGroup.attr(attribs);
2244
- }
2286
+ group.attr(attribs);
2287
+ if (markerGroup) {
2288
+ markerGroup.attrSetters = group.attrSetters;
2289
+ markerGroup.attr(attribs);
2290
+ }
2245
2291
 
2246
- // Run the animation
2247
- } else {
2248
- attribs = {
2249
- translateX: plotLeft,
2250
- translateY: plotTop,
2251
- scaleX: 1,
2252
- scaleY: 1
2253
- };
2254
- group.animate(attribs, animation);
2255
- if (markerGroup) {
2256
- markerGroup.animate(attribs, animation);
2257
- }
2292
+ // Run the animation
2293
+ } else {
2294
+ attribs = {
2295
+ translateX: plotLeft,
2296
+ translateY: plotTop,
2297
+ scaleX: 1,
2298
+ scaleY: 1
2299
+ };
2300
+ group.animate(attribs, animation);
2301
+ if (markerGroup) {
2302
+ markerGroup.animate(attribs, animation);
2303
+ }
2258
2304
 
2259
- // Delete this function to allow it only once
2260
- this.animate = null;
2305
+ // Delete this function to allow it only once
2306
+ this.animate = null;
2307
+ }
2261
2308
  }
2262
- }
2263
2309
 
2264
- // For non-polar charts, revert to the basic animation
2265
- } else {
2266
- proceed.call(this, init);
2267
- }
2268
- }
2269
-
2270
- // Define the animate method for both regular series and column series and their derivatives
2271
- wrap(seriesProto, 'animate', polarAnimate);
2272
- wrap(colProto, 'animate', polarAnimate);
2310
+ // For non-polar charts, revert to the basic animation
2311
+ } else {
2312
+ proceed.call(this, init);
2313
+ }
2314
+ }
2273
2315
 
2316
+ // Define the animate method for regular series
2317
+ wrap(seriesProto, 'animate', polarAnimate);
2274
2318
 
2275
- /**
2276
- * Throw in a couple of properties to let setTooltipPoints know we're indexing the points
2277
- * in degrees (0-360), not plot pixel width.
2278
- */
2279
- wrap(seriesProto, 'setTooltipPoints', function (proceed, renew) {
2319
+ /**
2320
+ * Throw in a couple of properties to let setTooltipPoints know we're indexing the points
2321
+ * in degrees (0-360), not plot pixel width.
2322
+ */
2323
+ wrap(seriesProto, 'setTooltipPoints', function (proceed, renew) {
2280
2324
 
2281
- if (this.chart.polar) {
2282
- extend(this.xAxis, {
2283
- tooltipLen: 360 // degrees are the resolution unit of the tooltipPoints array
2284
- });
2285
- }
2325
+ if (this.chart.polar) {
2326
+ extend(this.xAxis, {
2327
+ tooltipLen: 360 // degrees are the resolution unit of the tooltipPoints array
2328
+ });
2329
+ }
2286
2330
 
2287
- // Run uber method
2288
- return proceed.call(this, renew);
2289
- });
2331
+ // Run uber method
2332
+ return proceed.call(this, renew);
2333
+ });
2290
2334
 
2291
2335
 
2292
- /**
2293
- * Extend the column prototype's translate method
2294
- */
2295
- wrap(colProto, 'translate', function (proceed) {
2296
-
2297
- var xAxis = this.xAxis,
2298
- len = this.yAxis.len,
2299
- center = xAxis.center,
2300
- startAngleRad = xAxis.startAngleRad,
2301
- renderer = this.chart.renderer,
2302
- start,
2303
- points,
2304
- point,
2305
- i;
2306
-
2307
- this.preventPostTranslate = true;
2308
-
2309
- // Run uber method
2310
- proceed.call(this);
2311
-
2312
- // Postprocess plot coordinates
2313
- if (xAxis.isRadial) {
2314
- points = this.points;
2315
- i = points.length;
2316
- while (i--) {
2317
- point = points[i];
2318
- start = point.barX + startAngleRad;
2319
- point.shapeType = 'path';
2320
- point.shapeArgs = {
2321
- d: renderer.symbols.arc(
2322
- center[0],
2323
- center[1],
2324
- len - point.plotY,
2325
- null,
2326
- {
2327
- start: start,
2328
- end: start + point.pointWidth,
2329
- innerR: len - pick(point.yBottom, len)
2330
- }
2331
- )
2332
- };
2333
- this.toXY(point); // provide correct plotX, plotY for tooltip
2334
- }
2335
- }
2336
- });
2336
+ if (seriesTypes.column) {
2337
2337
 
2338
+ colProto = seriesTypes.column.prototype;
2339
+ /**
2340
+ * Define the animate method for columnseries
2341
+ */
2342
+ wrap(colProto, 'animate', polarAnimate);
2338
2343
 
2339
- /**
2340
- * Align column data labels outside the columns. #1199.
2341
- */
2342
- wrap(colProto, 'alignDataLabel', function (proceed, point, dataLabel, options, alignTo, isNew) {
2343
-
2344
- if (this.chart.polar) {
2345
- var angle = point.rectPlotX / Math.PI * 180,
2346
- align,
2347
- verticalAlign;
2348
-
2349
- // Align nicely outside the perimeter of the columns
2350
- if (options.align === null) {
2351
- if (angle > 20 && angle < 160) {
2352
- align = 'left'; // right hemisphere
2353
- } else if (angle > 200 && angle < 340) {
2354
- align = 'right'; // left hemisphere
2355
- } else {
2356
- align = 'center'; // top or bottom
2344
+
2345
+ /**
2346
+ * Extend the column prototype's translate method
2347
+ */
2348
+ wrap(colProto, 'translate', function (proceed) {
2349
+
2350
+ var xAxis = this.xAxis,
2351
+ len = this.yAxis.len,
2352
+ center = xAxis.center,
2353
+ startAngleRad = xAxis.startAngleRad,
2354
+ renderer = this.chart.renderer,
2355
+ start,
2356
+ points,
2357
+ point,
2358
+ i;
2359
+
2360
+ this.preventPostTranslate = true;
2361
+
2362
+ // Run uber method
2363
+ proceed.call(this);
2364
+
2365
+ // Postprocess plot coordinates
2366
+ if (xAxis.isRadial) {
2367
+ points = this.points;
2368
+ i = points.length;
2369
+ while (i--) {
2370
+ point = points[i];
2371
+ start = point.barX + startAngleRad;
2372
+ point.shapeType = 'path';
2373
+ point.shapeArgs = {
2374
+ d: renderer.symbols.arc(
2375
+ center[0],
2376
+ center[1],
2377
+ len - point.plotY,
2378
+ null,
2379
+ {
2380
+ start: start,
2381
+ end: start + point.pointWidth,
2382
+ innerR: len - pick(point.yBottom, len)
2383
+ }
2384
+ )
2385
+ };
2386
+ this.toXY(point); // provide correct plotX, plotY for tooltip
2387
+ }
2357
2388
  }
2358
- options.align = align;
2359
- }
2360
- if (options.verticalAlign === null) {
2361
- if (angle < 45 || angle > 315) {
2362
- verticalAlign = 'bottom'; // top part
2363
- } else if (angle > 135 && angle < 225) {
2364
- verticalAlign = 'top'; // bottom part
2389
+ });
2390
+
2391
+
2392
+ /**
2393
+ * Align column data labels outside the columns. #1199.
2394
+ */
2395
+ wrap(colProto, 'alignDataLabel', function (proceed, point, dataLabel, options, alignTo, isNew) {
2396
+
2397
+ if (this.chart.polar) {
2398
+ var angle = point.rectPlotX / Math.PI * 180,
2399
+ align,
2400
+ verticalAlign;
2401
+
2402
+ // Align nicely outside the perimeter of the columns
2403
+ if (options.align === null) {
2404
+ if (angle > 20 && angle < 160) {
2405
+ align = 'left'; // right hemisphere
2406
+ } else if (angle > 200 && angle < 340) {
2407
+ align = 'right'; // left hemisphere
2408
+ } else {
2409
+ align = 'center'; // top or bottom
2410
+ }
2411
+ options.align = align;
2412
+ }
2413
+ if (options.verticalAlign === null) {
2414
+ if (angle < 45 || angle > 315) {
2415
+ verticalAlign = 'bottom'; // top part
2416
+ } else if (angle > 135 && angle < 225) {
2417
+ verticalAlign = 'top'; // bottom part
2418
+ } else {
2419
+ verticalAlign = 'middle'; // left or right
2420
+ }
2421
+ options.verticalAlign = verticalAlign;
2422
+ }
2423
+
2424
+ seriesProto.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
2365
2425
  } else {
2366
- verticalAlign = 'middle'; // left or right
2426
+ proceed.call(this, point, dataLabel, options, alignTo, isNew);
2367
2427
  }
2368
- options.verticalAlign = verticalAlign;
2369
- }
2370
-
2371
- seriesProto.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
2372
- } else {
2373
- proceed.call(this, point, dataLabel, options, alignTo, isNew);
2374
- }
2375
2428
 
2376
- });
2429
+ });
2430
+ }
2377
2431
 
2378
- /**
2379
- * Extend the mouse tracker to return the tooltip position index in terms of
2380
- * degrees rather than pixels
2381
- */
2382
- wrap(pointerProto, 'getIndex', function (proceed, e) {
2383
- var ret,
2384
- chart = this.chart,
2385
- center,
2386
- x,
2387
- y;
2432
+
2433
+ /**
2434
+ * Extend the mouse tracker to return the tooltip position index in terms of
2435
+ * degrees rather than pixels
2436
+ */
2437
+ wrap(pointerProto, 'getIndex', function (proceed, e) {
2438
+ var ret,
2439
+ chart = this.chart,
2440
+ center,
2441
+ x,
2442
+ y;
2388
2443
 
2389
- if (chart.polar) {
2390
- center = chart.xAxis[0].center;
2391
- x = e.chartX - center[0] - chart.plotLeft;
2392
- y = e.chartY - center[1] - chart.plotTop;
2444
+ if (chart.polar) {
2445
+ center = chart.xAxis[0].center;
2446
+ x = e.chartX - center[0] - chart.plotLeft;
2447
+ y = e.chartY - center[1] - chart.plotTop;
2393
2448
 
2394
- ret = 180 - Math.round(Math.atan2(x, y) / Math.PI * 180);
2449
+ ret = 180 - Math.round(Math.atan2(x, y) / Math.PI * 180);
2395
2450
 
2396
- } else {
2451
+ } else {
2397
2452
 
2398
- // Run uber method
2399
- ret = proceed.call(this, e);
2400
- }
2401
- return ret;
2402
- });
2453
+ // Run uber method
2454
+ ret = proceed.call(this, e);
2455
+ }
2456
+ return ret;
2457
+ });
2403
2458
 
2404
- /**
2405
- * Extend getCoordinates to prepare for polar axis values
2406
- */
2407
- wrap(pointerProto, 'getCoordinates', function (proceed, e) {
2408
- var chart = this.chart,
2409
- ret = {
2410
- xAxis: [],
2411
- yAxis: []
2412
- };
2459
+ /**
2460
+ * Extend getCoordinates to prepare for polar axis values
2461
+ */
2462
+ wrap(pointerProto, 'getCoordinates', function (proceed, e) {
2463
+ var chart = this.chart,
2464
+ ret = {
2465
+ xAxis: [],
2466
+ yAxis: []
2467
+ };
2413
2468
 
2414
- if (chart.polar) {
2469
+ if (chart.polar) {
2415
2470
 
2416
- each(chart.axes, function (axis) {
2417
- var isXAxis = axis.isXAxis,
2418
- center = axis.center,
2419
- x = e.chartX - center[0] - chart.plotLeft,
2420
- y = e.chartY - center[1] - chart.plotTop;
2471
+ each(chart.axes, function (axis) {
2472
+ var isXAxis = axis.isXAxis,
2473
+ center = axis.center,
2474
+ x = e.chartX - center[0] - chart.plotLeft,
2475
+ y = e.chartY - center[1] - chart.plotTop;
2421
2476
 
2422
- ret[isXAxis ? 'xAxis' : 'yAxis'].push({
2423
- axis: axis,
2424
- value: axis.translate(
2425
- isXAxis ?
2426
- Math.PI - Math.atan2(x, y) : // angle
2427
- Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)), // distance from center
2428
- true
2429
- )
2477
+ ret[isXAxis ? 'xAxis' : 'yAxis'].push({
2478
+ axis: axis,
2479
+ value: axis.translate(
2480
+ isXAxis ?
2481
+ Math.PI - Math.atan2(x, y) : // angle
2482
+ Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)), // distance from center
2483
+ true
2484
+ )
2485
+ });
2430
2486
  });
2431
- });
2432
2487
 
2433
- } else {
2434
- ret = proceed.call(this, e);
2435
- }
2488
+ } else {
2489
+ ret = proceed.call(this, e);
2490
+ }
2436
2491
 
2437
- return ret;
2438
- });
2492
+ return ret;
2493
+ });
2494
+
2495
+ }());
2496
+
2439
2497
  }(Highcharts));