app/assets/javascripts/highcharts/highcharts-3d.js in highcharts-rails-5.0.0 vs app/assets/javascripts/highcharts/highcharts-3d.js in highcharts-rails-5.0.3

- old
+ new

@@ -1,7 +1,7 @@ /** - * @license Highcharts JS v5.0.0 (2016-09-29) + * @license Highcharts JS v5.0.3 (2016-11-18) * * 3D features for Highcharts JS * * @license: www.highcharts.com/license */ @@ -113,10 +113,29 @@ z: coordinate.z }; }); }; + /** + * Calculate a distance from camera to points - made for calculating zIndex of scatter points. + * Parameters: + * - coordinates: The coordinates of the specific point + * - chart: the chart + * Returns: + * - a distance from camera to point + */ + H.pointCameraDistance = function(coordinates, chart) { + var options3d = chart.options.chart.options3d, + cameraPosition = { + x: chart.plotWidth / 2, + y: chart.plotHeight / 2, + z: pick(options3d.depth, 1) * pick(options3d.viewDistance, 0) + options3d.depth + }, + distance = Math.sqrt(Math.pow(cameraPosition.x - coordinates.plotX, 2) + Math.pow(cameraPosition.y - coordinates.plotY, 2) + Math.pow(cameraPosition.z - coordinates.plotZ, 2)); + return distance; + }; + }(Highcharts)); (function(H) { /** * (c) 2010-2016 Torstein Honsi * @@ -603,25 +622,29 @@ anim = animObject(pick(animation, this.renderer.globalAnimation)); if (anim.duration) { params = merge(params); // Don't mutate the original object ca = suckOutCustom(params); + params.dummy = 1; // Params need to have a property in order for the step to run (#5765) if (ca) { to = ca; anim.step = function(a, fx) { function interpolate(key) { return from[key] + (pick(to[key], from[key]) - from[key]) * fx.pos; } - fx.elem.setPaths(merge(from, { - x: interpolate('x'), - y: interpolate('y'), - r: interpolate('r'), - innerR: interpolate('innerR'), - start: interpolate('start'), - end: interpolate('end') - })); + + if (fx.prop === 'dummy') { + fx.elem.setPaths(merge(from, { + x: interpolate('x'), + y: interpolate('y'), + r: interpolate('r'), + innerR: interpolate('innerR'), + start: interpolate('start'), + end: interpolate('end') + })); + } }; } animation = anim; // Only when duration (#5572) } return proceed.call(this, params, animation, complete); @@ -1985,15 +2008,15 @@ rawPoint.plotX = projectedPoint.x; rawPoint.plotY = projectedPoint.y; rawPoint.plotZ = projectedPoint.z; - } }); + wrap(seriesTypes.scatter.prototype, 'init', function(proceed, chart, options) { if (chart.is3d()) { // add a third coordinate this.axisTypes = ['xAxis', 'yAxis', 'zAxis']; this.pointArrayMap = ['x', 'y', 'z']; @@ -2014,9 +2037,20 @@ } else { this.tooltipOptions.pointFormat = default3dScatterTooltip; } } return result; + }); + + /** + * Updating zIndex for every point - based on the distance from point to camera + */ + wrap(seriesTypes.scatter.prototype, 'pointAttribs', function(proceed, point) { + var pointOptions = proceed.apply(this, [].slice.call(arguments, 1)); + if (point) { + pointOptions.zIndex = H.pointCameraDistance(point, this.chart); + } + return pointOptions; }); }(Highcharts)); (function(H) { /**