app/assets/javascripts/highcharts/modules/drilldown.js in highcharts-rails-3.0.10 vs app/assets/javascripts/highcharts/modules/drilldown.js in highcharts-rails-4.0.0

- old
+ new

@@ -106,11 +106,11 @@ }, ddOptions); pointIndex = inArray(point, oldSeries.points); // Record options for all current series each(oldSeries.chart.series, function (series) { - if (series.xAxis === xAxis && series.yAxis === yAxis) { + if (series.xAxis === xAxis) { levelSeries.push(series); levelSeriesOptions.push(series.userOptions); series.levelNumber = series.levelNumber || 0; } }); @@ -221,17 +221,19 @@ Chart.prototype.drillUp = function () { var chart = this, drilldownLevels = chart.drilldownLevels, levelNumber = drilldownLevels[drilldownLevels.length - 1].levelNumber, i = drilldownLevels.length, + chartSeries = chart.series, + seriesI = chartSeries.length, level, oldSeries, newSeries, oldExtremes, addSeries = function (seriesOptions) { var addedSeries; - each(chart.series, function (series) { + each(chartSeries, function (series) { if (series.userOptions === seriesOptions) { addedSeries = series; } }); @@ -248,24 +250,34 @@ level = drilldownLevels[i]; if (level.levelNumber === levelNumber) { drilldownLevels.pop(); + // Get the lower series by reference or id oldSeries = level.lowerSeries; + if (!oldSeries.chart) { // #2786 + while (seriesI--) { + if (chartSeries[seriesI].options.id === level.lowerSeriesOptions.id) { + oldSeries = chartSeries[seriesI]; + break; + } + } + } each(level.levelSeriesOptions, addSeries); fireEvent(chart, 'drillup', { seriesOptions: level.seriesOptions }); if (newSeries.type === oldSeries.type) { newSeries.drilldownLevel = level; - newSeries.options.animation = true; + newSeries.options.animation = chart.options.drilldown.animation; if (oldSeries.animateDrillupFrom) { oldSeries.animateDrillupFrom(level); } } + newSeries.levelNumber = levelNumber; oldSeries.remove(false); // Reset the zoom level of the upper series if (newSeries.xAxis) { @@ -367,39 +379,54 @@ * When drilling up, pull out the individual point graphics from the lower series * and animate them into the origin point in the upper series. */ ColumnSeries.prototype.animateDrillupFrom = function (level) { var animationOptions = this.chart.options.drilldown.animation, - group = this.group; + group = this.group, + series = this; + // Cancel mouse events on the series group (#2787) + each(series.trackerGroups, function (key) { + if (series[key]) { // we don't always have dataLabelsGroup + series[key].on('mouseover'); + } + }); + + delete this.group; each(this.points, function (point) { var graphic = point.graphic, - startColor = H.Color(point.color).rgba; + startColor = H.Color(point.color).rgba, + endColor = H.Color(level.color).rgba, + complete = function () { + graphic.destroy(); + if (group) { + group = group.destroy(); + } + }; if (graphic) { delete point.graphic; - /*jslint unparam: true*/ - graphic.animate(level.shapeArgs, H.merge(animationOptions, { - - step: function (val, fx) { - if (fx.prop === 'start') { - this.attr({ - fill: tweenColors(startColor, H.Color(level.color).rgba, fx.pos) - }); - } - }, - complete: function () { - graphic.destroy(); - if (group) { - group = group.destroy(); - } - } - })); - /*jslint unparam: false*/ + if (animationOptions) { + /*jslint unparam: true*/ + graphic.animate(level.shapeArgs, H.merge(animationOptions, { + step: function (val, fx) { + if (fx.prop === 'start' && startColor.length === 4 && endColor.length === 4) { + this.attr({ + fill: tweenColors(startColor, endColor, fx.pos) + }); + } + }, + complete: complete + })); + /*jslint unparam: false*/ + } else { + graphic.attr(level.shapeArgs); + complete(); + } } }); }; if (PieSeries) { @@ -424,13 +451,12 @@ /*jslint unparam: true*/ point.graphic .attr(H.merge(animateFrom, { start: start + i * startAngle, end: start + (i + 1) * startAngle - })) - .animate(point.shapeArgs, H.merge(animationOptions, { + }))[animationOptions ? 'animate' : 'attr'](point.shapeArgs, H.merge(animationOptions, { step: function (val, fx) { - if (fx.prop === 'start') { + if (fx.prop === 'start' && startColor.length === 4 && endColor.length === 4) { this.attr({ fill: tweenColors(startColor, endColor, fx.pos) }); } }