highcharts-rails 4.1.4 → 4.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v4.1.4 (2015-03-10)
2
+ * @license Highcharts JS v4.1.5 (2015-04-13)
3
3
  *
4
4
  * Standalone Highcharts Framework
5
5
  *
@@ -2,7 +2,7 @@
2
2
  // @compilation_level SIMPLE_OPTIMIZATIONS
3
3
 
4
4
  /**
5
- * @license Highcharts JS v4.1.4 (2015-03-10)
5
+ * @license Highcharts JS v4.1.5 (2015-04-13)
6
6
  *
7
7
  * (c) 2009-2013 Torstein Hønsi
8
8
  *
@@ -849,7 +849,9 @@ Highcharts.wrap(Highcharts.seriesTypes.column.prototype, 'translate', function (
849
849
  tooltipPos = perspective([{ x: tooltipPos[0], y: tooltipPos[1], z: z }], chart, false)[0];
850
850
  point.tooltipPos = [tooltipPos.x, tooltipPos.y];
851
851
  }
852
- });
852
+ });
853
+ // store for later use #4067
854
+ series.z = z;
853
855
  });
854
856
 
855
857
  Highcharts.wrap(Highcharts.seriesTypes.column.prototype, 'animate', function (proceed) {
@@ -929,14 +931,15 @@ function draw3DPoints(proceed) {
929
931
  // Do not do this if the chart is not 3D
930
932
  if (this.chart.is3d()) {
931
933
  var grouping = this.chart.options.plotOptions.column.grouping;
932
- if (grouping !== undefined && !grouping && this.group.zIndex !== undefined) {
934
+ if (grouping !== undefined && !grouping && this.group.zIndex !== undefined && !this.zIndexSet) {
933
935
  this.group.attr({zIndex : (this.group.zIndex * 10)});
936
+ this.zIndexSet = true; // #4062 set zindex only once
934
937
  }
935
938
 
936
939
  var options = this.options,
937
940
  states = this.options.states;
938
941
 
939
- this.borderWidth = options.borderWidth = options.edgeWidth || 1;
942
+ this.borderWidth = options.borderWidth = defined(options.edgeWidth) ? options.edgeWidth : 1; //#4055
940
943
 
941
944
  Highcharts.each(this.data, function (point) {
942
945
  if (point.y !== null) {
@@ -965,7 +968,7 @@ Highcharts.wrap(Highcharts.Series.prototype, 'alignDataLabel', function (proceed
965
968
  var args = arguments,
966
969
  alignTo = args[4];
967
970
 
968
- var pos = ({x: alignTo.x, y: alignTo.y, z: 0});
971
+ var pos = ({x: alignTo.x, y: alignTo.y, z: series.z});
969
972
  pos = perspective([pos], chart, true)[0];
970
973
  alignTo.x = pos.x;
971
974
  alignTo.y = pos.y;
@@ -2,7 +2,7 @@
2
2
  // @compilation_level SIMPLE_OPTIMIZATIONS
3
3
 
4
4
  /**
5
- * @license Highcharts JS v4.1.4 (2015-03-10)
5
+ * @license Highcharts JS v4.1.5 (2015-04-13)
6
6
  *
7
7
  * (c) 2009-2014 Torstein Honsi
8
8
  *
@@ -1563,8 +1563,6 @@ seriesTypes.waterfall = extendClass(seriesTypes.column, {
1563
1563
 
1564
1564
  upColorProp: 'fill',
1565
1565
 
1566
- pointArrayMap: ['low', 'y'],
1567
-
1568
1566
  pointValKey: 'y',
1569
1567
 
1570
1568
  /**
@@ -1639,6 +1637,11 @@ seriesTypes.waterfall = extendClass(seriesTypes.column, {
1639
1637
  }
1640
1638
  previousY += yValue;
1641
1639
  }
1640
+ // #3952 Negative sum or intermediate sum not rendered correctly
1641
+ if (shapeArgs.height < 0) {
1642
+ shapeArgs.y += shapeArgs.height;
1643
+ shapeArgs.height *= -1;
1644
+ }
1642
1645
 
1643
1646
  point.plotY = shapeArgs.y = mathRound(shapeArgs.y) - (series.borderWidth % 2) / 2;
1644
1647
  shapeArgs.height = mathMax(mathRound(shapeArgs.height), 0.001); // #3151
@@ -2141,7 +2144,10 @@ Axis.prototype.beforePadding = function () {
2141
2144
  pointerProto = Pointer.prototype,
2142
2145
  colProto;
2143
2146
 
2144
- seriesProto.searchPolarPoint = function (e) {
2147
+ /**
2148
+ * Search a k-d tree by the point angle, used for shared tooltips in polar charts
2149
+ */
2150
+ seriesProto.searchPointByAngle = function (e) {
2145
2151
  var series = this,
2146
2152
  chart = series.chart,
2147
2153
  xAxis = series.xAxis,
@@ -2149,28 +2155,28 @@ Axis.prototype.beforePadding = function () {
2149
2155
  plotX = e.chartX - center[0] - chart.plotLeft,
2150
2156
  plotY = e.chartY - center[1] - chart.plotTop;
2151
2157
 
2152
- this.kdAxisArray = ['clientX'];
2153
- e = {
2158
+ return this.searchKDTree({
2154
2159
  clientX: 180 + (Math.atan2(plotX, plotY) * (-180 / Math.PI))
2155
- };
2156
- return this.searchKDTree(e);
2160
+ });
2157
2161
 
2158
2162
  };
2159
2163
 
2164
+ /**
2165
+ * Wrap the buildKDTree function so that it searches by angle (clientX) in case of shared tooltip,
2166
+ * and by two dimensional distance in case of non-shared.
2167
+ */
2160
2168
  wrap(seriesProto, 'buildKDTree', function (proceed) {
2161
2169
  if (this.chart.polar) {
2162
- this.kdAxisArray = ['clientX'];
2170
+ if (this.kdByAngle) {
2171
+ this.searchPoint = this.searchPointByAngle;
2172
+ } else {
2173
+ this.kdDimensions = 2;
2174
+ this.kdComparer = 'distR';
2175
+ }
2163
2176
  }
2164
2177
  proceed.apply(this);
2165
2178
  });
2166
-
2167
- wrap(seriesProto, 'searchPoint', function (proceed, e) {
2168
- if (this.chart.polar) {
2169
- return this.searchPolarPoint(e);
2170
- } else {
2171
- return proceed.call(this, e);
2172
- }
2173
- });
2179
+
2174
2180
  /**
2175
2181
  * Translate a point's plotX and plotY from the internal angle and radius measures to
2176
2182
  * true plotX, plotY coordinates
@@ -2186,18 +2192,22 @@ Axis.prototype.beforePadding = function () {
2186
2192
  point.rectPlotX = plotX;
2187
2193
  point.rectPlotY = plotY;
2188
2194
 
2189
- // Record the angle in degrees for use in tooltip
2190
- clientX = ((plotX / Math.PI * 180) + this.xAxis.pane.options.startAngle) % 360;
2191
- if (clientX < 0) { // #2665
2192
- clientX += 360;
2193
- }
2194
- point.clientX = clientX;
2195
-
2196
-
2197
2195
  // Find the polar plotX and plotY
2198
2196
  xy = this.xAxis.postTranslate(point.plotX, this.yAxis.len - plotY);
2199
2197
  point.plotX = point.polarPlotX = xy.x - chart.plotLeft;
2200
2198
  point.plotY = point.polarPlotY = xy.y - chart.plotTop;
2199
+
2200
+ // If shared tooltip, record the angle in degrees in order to align X points. Otherwise,
2201
+ // use a standard k-d tree to get the nearest point in two dimensions.
2202
+ if (this.kdByAngle) {
2203
+ clientX = ((plotX / Math.PI * 180) + this.xAxis.pane.options.startAngle) % 360;
2204
+ if (clientX < 0) { // #2665
2205
+ clientX += 360;
2206
+ }
2207
+ point.clientX = clientX;
2208
+ } else {
2209
+ point.clientX = point.plotX;
2210
+ }
2201
2211
  };
2202
2212
 
2203
2213
  /**
@@ -2345,17 +2355,25 @@ Axis.prototype.beforePadding = function () {
2345
2355
  * center.
2346
2356
  */
2347
2357
  wrap(seriesProto, 'translate', function (proceed) {
2348
-
2358
+ var chart = this.chart,
2359
+ points,
2360
+ i;
2361
+
2349
2362
  // Run uber method
2350
2363
  proceed.call(this);
2351
2364
 
2352
2365
  // Postprocess plot coordinates
2353
- if (this.chart.polar && !this.preventPostTranslate) {
2354
- var points = this.points,
2366
+ if (chart.polar) {
2367
+ this.kdByAngle = chart.tooltip.shared;
2368
+
2369
+ if (!this.preventPostTranslate) {
2370
+ points = this.points;
2355
2371
  i = points.length;
2356
- while (i--) {
2357
- // Translate plotX, plotY from angle and radius to true plot coordinates
2358
- this.toXY(points[i]);
2372
+
2373
+ while (i--) {
2374
+ // Translate plotX, plotY from angle and radius to true plot coordinates
2375
+ this.toXY(points[i]);
2376
+ }
2359
2377
  }
2360
2378
  }
2361
2379
  });
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Highcharts JS v4.1.4 (2015-03-10)
2
+ * Highcharts JS v4.1.5 (2015-04-13)
3
3
  * Highcharts Broken Axis module
4
4
  *
5
5
  * Author: Stephane Vanraes, Torstein Honsi
@@ -2908,7 +2908,7 @@ if (CanvasRenderingContext2D) {
2908
2908
  });
2909
2909
  }
2910
2910
  }/**
2911
- * @license Highcharts JS v4.1.4 (2015-03-10)
2911
+ * @license Highcharts JS v4.1.5 (2015-04-13)
2912
2912
  * CanVGRenderer Extension module
2913
2913
  *
2914
2914
  * (c) 2011-2012 Torstein Honsi, Erik Olsson
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license Highcharts JS v4.1.4 (2015-03-10)
2
+ * @license Highcharts JS v4.1.5 (2015-04-13)
3
3
  * Data module
4
4
  *
5
5
  * (c) 2012-2014 Torstein Honsi
@@ -23,9 +23,9 @@
23
23
  seriesTypes = H.seriesTypes,
24
24
  PieSeries = seriesTypes.pie,
25
25
  ColumnSeries = seriesTypes.column,
26
+ Tick = H.Tick,
26
27
  fireEvent = HighchartsAdapter.fireEvent,
27
28
  inArray = HighchartsAdapter.inArray,
28
- dupes = [],
29
29
  ddSeriesId = 1;
30
30
 
31
31
  // Utilities
@@ -42,8 +42,7 @@
42
42
 
43
43
  // Unsupported color, return to-color (#3920)
44
44
  if (!to.rgba.length || !from.rgba.length) {
45
- Highcharts.error(23);
46
- ret = to.raw;
45
+ ret = to.raw || 'none';
47
46
 
48
47
  // Interpolate
49
48
  } else {
@@ -128,9 +127,21 @@
128
127
  levelSeries = [],
129
128
  levelSeriesOptions = [],
130
129
  level,
131
- levelNumber;
130
+ levelNumber,
131
+ last;
132
132
 
133
+ if (!this.drilldownLevels) {
134
+ this.drilldownLevels = [];
135
+ }
136
+
133
137
  levelNumber = oldSeries.options._levelNumber || 0;
138
+
139
+ // See if we can reuse the registered series from last run
140
+ last = this.drilldownLevels[this.drilldownLevels.length - 1];
141
+ if (last && last.levelNumber !== levelNumber) {
142
+ last = undefined;
143
+ }
144
+
134
145
 
135
146
  ddOptions = extend({
136
147
  color: color,
@@ -140,12 +151,18 @@
140
151
 
141
152
  // Record options for all current series
142
153
  each(oldSeries.chart.series, function (series) {
143
- if (series.xAxis === xAxis) {
144
- levelSeries.push(series);
154
+ if (series.xAxis === xAxis && !series.isDrilling) {
145
155
  series.options._ddSeriesId = series.options._ddSeriesId || ddSeriesId++;
146
156
  series.options._colorIndex = series.userOptions._colorIndex;
147
- levelSeriesOptions.push(series.options);
148
157
  series.options._levelNumber = series.options._levelNumber || levelNumber; // #3182
158
+
159
+ if (last) {
160
+ levelSeries = last.levelSeries;
161
+ levelSeriesOptions = last.levelSeriesOptions;
162
+ } else {
163
+ levelSeries.push(series);
164
+ levelSeriesOptions.push(series.options);
165
+ }
149
166
  }
150
167
  });
151
168
 
@@ -169,10 +186,7 @@
169
186
  }
170
187
  };
171
188
 
172
- // Generate and push it to a lookup array
173
- if (!this.drilldownLevels) {
174
- this.drilldownLevels = [];
175
- }
189
+ // Push it to the lookup array
176
190
  this.drilldownLevels.push(level);
177
191
 
178
192
  newSeries = level.lowerSeries = this.addSeries(ddOptions, false);
@@ -298,7 +312,8 @@
298
312
  if (!oldSeries.chart) { // #2786
299
313
  seriesI = chartSeries.length; // #2919
300
314
  while (seriesI--) {
301
- if (chartSeries[seriesI].options.id === level.lowerSeriesOptions.id) {
315
+ if (chartSeries[seriesI].options.id === level.lowerSeriesOptions.id &&
316
+ chartSeries[seriesI].options._levelNumber === levelNumber + 1) { // #3867
302
317
  oldSeries = chartSeries[seriesI];
303
318
  break;
304
319
  }
@@ -342,7 +357,7 @@
342
357
  .align();
343
358
  }
344
359
 
345
- dupes.length = []; // #3315
360
+ this.ddDupes.length = []; // #3315
346
361
  };
347
362
 
348
363
 
@@ -513,11 +528,15 @@
513
528
  drilldown = chart.options.drilldown,
514
529
  i = (drilldown.series || []).length,
515
530
  seriesOptions;
531
+
532
+ if (!chart.ddDupes) {
533
+ chart.ddDupes = [];
534
+ }
516
535
 
517
536
  while (i-- && !seriesOptions) {
518
- if (drilldown.series[i].id === this.drilldown && inArray(this.drilldown, dupes) === -1) {
537
+ if (drilldown.series[i].id === this.drilldown && inArray(this.drilldown, chart.ddDupes) === -1) {
519
538
  seriesOptions = drilldown.series[i];
520
- dupes.push(this.drilldown);
539
+ chart.ddDupes.push(this.drilldown);
521
540
  }
522
541
  }
523
542
 
@@ -527,7 +546,7 @@
527
546
  point: this,
528
547
  seriesOptions: seriesOptions,
529
548
  category: category,
530
- points: category !== undefined && this.series.xAxis.ticks[category].label.ddPoints.slice(0)
549
+ points: category !== undefined && this.series.xAxis.ddPoints[category].slice(0)
531
550
  });
532
551
 
533
552
  if (seriesOptions) {
@@ -543,13 +562,70 @@
543
562
  * Drill down to a given category. This is the same as clicking on an axis label.
544
563
  */
545
564
  H.Axis.prototype.drilldownCategory = function (x) {
546
- each(this.ticks[x].label.ddPoints, function (point) {
547
- if (point.series && point.series.visible && point.doDrilldown) { // #3197
565
+ var key,
566
+ point,
567
+ ddPointsX = this.ddPoints[x];
568
+ for (key in ddPointsX) {
569
+ point = ddPointsX[key];
570
+ if (point && point.series && point.series.visible && point.doDrilldown) { // #3197
548
571
  point.doDrilldown(true, x);
549
572
  }
550
- });
573
+ }
551
574
  this.chart.applyDrilldown();
552
575
  };
576
+
577
+ /**
578
+ * Create and return a collection of points associated with the X position. Reset it for each level.
579
+ */
580
+ H.Axis.prototype.getDDPoints = function (x, levelNumber) {
581
+ var ddPoints = this.ddPoints;
582
+ if (!ddPoints) {
583
+ this.ddPoints = ddPoints = {};
584
+ }
585
+ if (!ddPoints[x]) {
586
+ ddPoints[x] = [];
587
+ }
588
+ if (ddPoints[x].levelNumber !== levelNumber) {
589
+ ddPoints[x].length = 0; // reset
590
+ }
591
+ return ddPoints[x];
592
+ };
593
+
594
+
595
+ /**
596
+ * Make a tick label drillable, or remove drilling on update
597
+ */
598
+ Tick.prototype.drillable = function () {
599
+ var pos = this.pos,
600
+ label = this.label,
601
+ axis = this.axis,
602
+ ddPointsX = axis.ddPoints && axis.ddPoints[pos];
603
+
604
+ if (label && ddPointsX && ddPointsX.length) {
605
+ if (!label.basicStyles) {
606
+ label.basicStyles = H.merge(label.styles);
607
+ }
608
+ label
609
+ .addClass('highcharts-drilldown-axis-label')
610
+ .css(axis.chart.options.drilldown.activeAxisLabelStyle)
611
+ .on('click', function () {
612
+ axis.drilldownCategory(pos);
613
+ });
614
+
615
+ } else if (label && label.basicStyles) {
616
+ label.styles = {}; // reset for full overwrite of styles
617
+ label.css(label.basicStyles);
618
+ label.on('click', null); // #3806
619
+ }
620
+ };
621
+
622
+ /**
623
+ * Always keep the drillability updated (#3951)
624
+ */
625
+ wrap(Tick.prototype, 'addLabel', function (proceed) {
626
+ proceed.call(this);
627
+ this.drillable();
628
+ });
553
629
 
554
630
 
555
631
  /**
@@ -558,20 +634,10 @@
558
634
  */
559
635
  wrap(H.Point.prototype, 'init', function (proceed, series, options, x) {
560
636
  var point = proceed.call(this, series, options, x),
561
- chart = series.chart,
562
- tick = series.xAxis && series.xAxis.ticks[x],
563
- tickLabel = tick && tick.label;
637
+ xAxis = series.xAxis,
638
+ tick = xAxis && xAxis.ticks[x],
639
+ ddPointsX = xAxis && xAxis.getDDPoints(x, series.options._levelNumber);
564
640
 
565
- // Create a collection of points associated with the label. Reset it for each level.
566
- if (tickLabel) {
567
- if (!tickLabel.ddPoints) {
568
- tickLabel.ddPoints = [];
569
- }
570
- if (tickLabel.levelNumber !== series.options._levelNumber) {
571
- tickLabel.ddPoints.length = 0; // reset
572
- }
573
- }
574
-
575
641
  if (point.drilldown) {
576
642
 
577
643
  // Add the click event to the point
@@ -587,26 +653,18 @@
587
653
  }
588
654
  });*/
589
655
 
590
- // Make axis labels clickable
591
- if (tickLabel) {
592
- if (!tickLabel.basicStyles) {
593
- tickLabel.basicStyles = H.merge(tickLabel.styles);
594
- }
595
- tickLabel
596
- .addClass('highcharts-drilldown-axis-label')
597
- .css(chart.options.drilldown.activeAxisLabelStyle)
598
- .on('click', function () {
599
- series.xAxis.drilldownCategory(x);
600
- });
601
-
602
- tickLabel.ddPoints.push(point);
603
- tickLabel.levelNumber = series.options._levelNumber;
604
-
656
+
657
+ // Register drilldown points on this X value
658
+ if (ddPointsX) {
659
+ ddPointsX.push(point);
660
+ ddPointsX.levelNumber = series.options._levelNumber;
605
661
  }
606
- } else if (tickLabel && tickLabel.basicStyles && tickLabel.levelNumber !== series.options._levelNumber) {
607
- tickLabel.styles = {}; // reset for full overwrite of styles
608
- tickLabel.css(tickLabel.basicStyles);
609
- tickLabel.on('click', null); // #3806
662
+
663
+ }
664
+
665
+ // Add or remove click handler and style on the tick label
666
+ if (tick) {
667
+ tick.drillable();
610
668
  }
611
669
 
612
670
  return point;
@@ -623,10 +681,7 @@
623
681
  .attr({
624
682
  'class': 'highcharts-drilldown-data-label'
625
683
  })
626
- .css(css)
627
- .on('click', function () {
628
- point.doDrilldown();
629
- });
684
+ .css(css);
630
685
  }
631
686
  });
632
687
  });