app/assets/javascripts/highcharts/modules/drilldown.js in highcharts-rails-4.2.6 vs app/assets/javascripts/highcharts/modules/drilldown.js in highcharts-rails-4.2.7

- old
+ new

@@ -82,11 +82,10 @@ fontWeight: 'bold', textDecoration: 'underline' }, activeDataLabelStyle: { cursor: 'pointer', - color: '#0d233a', fontWeight: 'bold', textDecoration: 'underline' }, animation: { duration: 500 @@ -177,11 +176,11 @@ seriesOptions: oldSeries.options, levelSeriesOptions: levelSeriesOptions, levelSeries: levelSeries, shapeArgs: point.shapeArgs, bBox: point.graphic ? point.graphic.getBBox() : {}, // no graphic in line series with markers disabled - color: color, + color: point.isNull ? new Highcharts.Color(color).setOpacity(0).get() : color, lowerSeriesOptions: ddOptions, pointOptions: oldSeries.options.data[pointIndex], pointIndex: pointIndex, oldExtremes: { xMin: xAxis && xAxis.userMin, @@ -512,19 +511,21 @@ angle = animateFrom.end - start, startAngle = angle / this.points.length; if (!init) { each(this.points, function (point, i) { - point.graphic - .attr(H.merge(animateFrom, { - start: start + i * startAngle, - end: start + (i + 1) * startAngle, - fill: level.color - }))[animationOptions ? 'animate' : 'attr']( - extend(point.shapeArgs, { fill: point.color }), - animationOptions - ); + if (point.graphic) { + point.graphic + .attr(H.merge(animateFrom, { + start: start + i * startAngle, + end: start + (i + 1) * startAngle, + fill: level.color + }))[animationOptions ? 'animate' : 'attr']( + extend(point.shapeArgs, { fill: point.color }), + animationOptions + ); + } }); this.animate = null; } } }); @@ -553,11 +554,11 @@ fireEvent(chart, 'drilldown', { point: this, seriesOptions: seriesOptions, category: category, originalEvent: originalEvent, - points: category !== undefined && this.series.xAxis.ddPoints[category].slice(0) + points: category !== undefined && this.series.xAxis.getDDPoints(category).slice(0) }, function (e) { var chart = e.point.series && e.point.series.chart, seriesOptions = e.seriesOptions; if (chart && seriesOptions) { if (_holdRedraw) { @@ -575,62 +576,68 @@ * Drill down to a given category. This is the same as clicking on an axis label. */ H.Axis.prototype.drilldownCategory = function (x, e) { var key, point, - ddPointsX = this.ddPoints[x]; + ddPointsX = this.getDDPoints(x); for (key in ddPointsX) { point = ddPointsX[key]; if (point && point.series && point.series.visible && point.doDrilldown) { // #3197 point.doDrilldown(true, x, e); } } this.chart.applyDrilldown(); }; /** - * Create and return a collection of points associated with the X position. Reset it for each level. - */ - H.Axis.prototype.getDDPoints = function (x, levelNumber) { - var ddPoints = this.ddPoints; - if (!ddPoints) { - this.ddPoints = ddPoints = {}; - } - if (!ddPoints[x]) { - ddPoints[x] = []; - } - if (ddPoints[x].levelNumber !== levelNumber) { - ddPoints[x].length = 0; // reset - } - return ddPoints[x]; + * Return drillable points for this specific X value + */ + H.Axis.prototype.getDDPoints = function (x) { + var ret = []; + each(this.series, function (series) { + var i, + xData = series.xData, + points = series.points; + + for (i = 0; i < xData.length; i++) { + if (xData[i] === x && series.options.data[i].drilldown) { + ret.push(points ? points[i] : true); + break; + } + } + }); + return ret; }; /** * Make a tick label drillable, or remove drilling on update */ Tick.prototype.drillable = function () { var pos = this.pos, label = this.label, axis = this.axis, - ddPointsX = axis.ddPoints && axis.ddPoints[pos]; + isDrillable = axis.coll === 'xAxis' && axis.getDDPoints, + ddPointsX = isDrillable && axis.getDDPoints(pos); - if (label && ddPointsX && ddPointsX.length) { - if (!label.basicStyles) { - label.basicStyles = H.merge(label.styles); - } - label - .addClass('highcharts-drilldown-axis-label') - .css(axis.chart.options.drilldown.activeAxisLabelStyle) - .on('click', function (e) { - axis.drilldownCategory(pos, e); - }); + if (isDrillable) { + if (label && ddPointsX.length) { + if (!label.basicStyles) { + label.basicStyles = H.merge(label.styles); + } + label + .addClass('highcharts-drilldown-axis-label') + .css(axis.chart.options.drilldown.activeAxisLabelStyle) + .on('click', function (e) { + axis.drilldownCategory(pos, e); + }); - } else if (label && label.basicStyles) { - label.styles = {}; // reset for full overwrite of styles - label.css(label.basicStyles); - label.on('click', null); // #3806 + } else if (label && label.basicStyles) { + label.styles = {}; // reset for full overwrite of styles + label.css(label.basicStyles); + label.on('click', null); // #3806 + } } }; /** * Always keep the drillability updated (#3951) @@ -646,12 +653,11 @@ * list of points associated to that label. */ wrap(H.Point.prototype, 'init', function (proceed, series, options, x) { var point = proceed.call(this, series, options, x), xAxis = series.xAxis, - tick = xAxis && xAxis.ticks[x], - ddPointsX = xAxis && xAxis.getDDPoints(x, series.options._levelNumber); + tick = xAxis && xAxis.ticks[x]; if (point.drilldown) { // Add the click event to the point H.addEvent(point, 'click', function (e) { @@ -667,16 +673,9 @@ H.addEvent(this, 'click', function () { this.doDrilldown(); }); } });*/ - - - // Register drilldown points on this X value - if (ddPointsX) { - ddPointsX.push(point); - ddPointsX.levelNumber = series.options._levelNumber; - } } // Add or remove click handler and style on the tick label if (tick) {