app/assets/javascripts/highstocks/modules/drilldown.js in highstocks-rails-1.3.10 vs app/assets/javascripts/highstocks/modules/drilldown.js in highstocks-rails-2.0.4
- old
+ new
@@ -1,14 +1,15 @@
-(function(h){function s(a,b,e){return"rgba("+[Math.round(a[0]+(b[0]-a[0])*e),Math.round(a[1]+(b[1]-a[1])*e),Math.round(a[2]+(b[2]-a[2])*e),a[3]+(b[3]-a[3])*e].join(",")+")"}var t=function(){},m=h.getOptions(),i=h.each,o=h.extend,w=h.format,p=h.wrap,j=h.Chart,l=h.seriesTypes,u=l.pie,k=l.column,v=HighchartsAdapter.fireEvent,x=HighchartsAdapter.inArray;o(m.lang,{drillUpText:"◁ Back to {series.name}"});m.drilldown={activeAxisLabelStyle:{cursor:"pointer",color:"#0d233a",fontWeight:"bold",textDecoration:"underline"},
-activeDataLabelStyle:{cursor:"pointer",color:"#0d233a",fontWeight:"bold",textDecoration:"underline"},animation:{duration:500},drillUpButton:{position:{align:"right",x:-10,y:10}}};h.SVGRenderer.prototype.Element.prototype.fadeIn=function(a){this.attr({opacity:0.1,visibility:"inherit"}).animate({opacity:1},a||{duration:250})};j.prototype.addSeriesAsDrilldown=function(a,b){this.addSingleSeriesAsDrilldown(a,b);this.applyDrilldown()};j.prototype.addSingleSeriesAsDrilldown=function(a,b){var e=a.series,
-d=e.xAxis,c=e.yAxis,f;f=a.color||e.color;var g,h=[],n=[],q;q=e.levelNumber||0;b=o({color:f},b);g=x(a,e.points);i(e.chart.series,function(a){if(a.xAxis===d&&a.yAxis===c)h.push(a),n.push(a.userOptions),a.levelNumber=a.levelNumber||0});f={levelNumber:q,seriesOptions:e.userOptions,levelSeriesOptions:n,levelSeries:h,shapeArgs:a.shapeArgs,bBox:a.graphic.getBBox(),color:f,lowerSeriesOptions:b,pointOptions:e.options.data[g],pointIndex:g,oldExtremes:{xMin:d&&d.userMin,xMax:d&&d.userMax,yMin:c&&c.userMin,yMax:c&&
-c.userMax}};if(!this.drilldownLevels)this.drilldownLevels=[];this.drilldownLevels.push(f);f=f.lowerSeries=this.addSeries(b,!1);f.levelNumber=q+1;if(d)d.oldPos=d.pos,d.userMin=d.userMax=null,c.userMin=c.userMax=null;if(e.type===f.type)f.animate=f.animateDrilldown||t,f.options.animation=!0};j.prototype.applyDrilldown=function(){var a=this.drilldownLevels,b=a[a.length-1].levelNumber;i(this.drilldownLevels,function(a){a.levelNumber===b&&i(a.levelSeries,function(a){a.levelNumber===b&&a.remove(!1)})});
-this.redraw();this.showDrillUpButton()};j.prototype.getDrilldownBackText=function(){var a=this.drilldownLevels[this.drilldownLevels.length-1];a.series=a.seriesOptions;return w(this.options.lang.drillUpText,a)};j.prototype.showDrillUpButton=function(){var a=this,b=this.getDrilldownBackText(),e=a.options.drilldown.drillUpButton,d,c;this.drillUpButton?this.drillUpButton.attr({text:b}).align():(c=(d=e.theme)&&d.states,this.drillUpButton=this.renderer.button(b,null,null,function(){a.drillUp()},d,c&&c.hover,
-c&&c.select).attr({align:e.position.align,zIndex:9}).add().align(e.position,!1,e.relativeTo||"plotBox"))};j.prototype.drillUp=function(){for(var a=this,b=a.drilldownLevels,e=b[b.length-1].levelNumber,d=b.length,c,f,g,h,n=function(b){var d;i(a.series,function(a){a.userOptions===b&&(d=a)});d=d||a.addSeries(b,!1);if(d.type===f.type&&d.animateDrillupTo)d.animate=d.animateDrillupTo;b===c.seriesOptions&&(g=d)};d--;)if(c=b[d],c.levelNumber===e){b.pop();f=c.lowerSeries;i(c.levelSeriesOptions,n);v(a,"drillup",
-{seriesOptions:c.seriesOptions});if(g.type===f.type)g.drilldownLevel=c,g.options.animation=!0,f.animateDrillupFrom&&f.animateDrillupFrom(c);f.remove(!1);if(g.xAxis)h=c.oldExtremes,g.xAxis.setExtremes(h.xMin,h.xMax,!1),g.yAxis.setExtremes(h.yMin,h.yMax,!1)}this.redraw();this.drilldownLevels.length===0?this.drillUpButton=this.drillUpButton.destroy():this.drillUpButton.attr({text:this.getDrilldownBackText()}).align()};k.prototype.supportsDrilldown=!0;k.prototype.animateDrillupTo=function(a){if(!a){var b=
-this,e=b.drilldownLevel;i(this.points,function(a){a.graphic.hide();a.dataLabel&&a.dataLabel.hide();a.connector&&a.connector.hide()});setTimeout(function(){i(b.points,function(a,b){var f=b===(e&&e.pointIndex)?"show":"fadeIn",g=f==="show"?!0:void 0;a.graphic[f](g);if(a.dataLabel)a.dataLabel[f](g);if(a.connector)a.connector[f](g)})},Math.max(this.chart.options.drilldown.animation.duration-50,0));this.animate=t}};k.prototype.animateDrilldown=function(a){var b=this,e=this.chart.drilldownLevels,d=this.chart.drilldownLevels[this.chart.drilldownLevels.length-
-1].shapeArgs,c=this.chart.options.drilldown.animation;if(!a)i(e,function(a){if(b.userOptions===a.lowerSeriesOptions)d=a.shapeArgs}),d.x+=this.xAxis.oldPos-this.xAxis.pos,i(this.points,function(a){a.graphic&&a.graphic.attr(d).animate(a.shapeArgs,c);a.dataLabel&&a.dataLabel.fadeIn(c)}),this.animate=null};k.prototype.animateDrillupFrom=function(a){var b=this.chart.options.drilldown.animation,e=this.group;delete this.group;i(this.points,function(d){var c=d.graphic,f=h.Color(d.color).rgba;c&&(delete d.graphic,
-c.animate(a.shapeArgs,h.merge(b,{step:function(b,c){c.prop==="start"&&this.attr({fill:s(f,h.Color(a.color).rgba,c.pos)})},complete:function(){c.destroy();e&&(e=e.destroy())}})))})};u&&o(u.prototype,{supportsDrilldown:!0,animateDrillupTo:k.prototype.animateDrillupTo,animateDrillupFrom:k.prototype.animateDrillupFrom,animateDrilldown:function(a){var b=this.chart.drilldownLevels[this.chart.drilldownLevels.length-1],e=this.chart.options.drilldown.animation,d=b.shapeArgs,c=d.start,f=(d.end-c)/this.points.length,
-g=h.Color(b.color).rgba;if(!a)i(this.points,function(a,b){var i=h.Color(a.color).rgba;a.graphic.attr(h.merge(d,{start:c+b*f,end:c+(b+1)*f})).animate(a.shapeArgs,h.merge(e,{step:function(a,b){b.prop==="start"&&this.attr({fill:s(g,i,b.pos)})}}))}),this.animate=null}});h.Point.prototype.doDrilldown=function(a){for(var b=this.series.chart,e=b.options.drilldown,d=(e.series||[]).length,c;d--&&!c;)e.series[d].id===this.drilldown&&(c=e.series[d]);v(b,"drilldown",{point:this,seriesOptions:c});c&&(a?b.addSingleSeriesAsDrilldown(this,
-c):b.addSeriesAsDrilldown(this,c))};p(h.Point.prototype,"init",function(a,b,e,d){var c=a.call(this,b,e,d),f=b.chart,g=(a=b.xAxis&&b.xAxis.ticks[d])&&a.label;if(c.drilldown){if(h.addEvent(c,"click",function(){c.doDrilldown()}),g){if(!g._basicStyle)g._basicStyle=g.element.getAttribute("style");g.addClass("highcharts-drilldown-axis-label").css(f.options.drilldown.activeAxisLabelStyle).on("click",function(){i(g.ddPoints,function(a){a.doDrilldown&&a.doDrilldown(!0)});f.applyDrilldown()});if(!g.ddPoints)g.ddPoints=
-[];g.ddPoints.push(c)}}else g&&g._basicStyle&&g.element.setAttribute("style",g._basicStyle);return c});p(h.Series.prototype,"drawDataLabels",function(a){var b=this.chart.options.drilldown.activeDataLabelStyle;a.call(this);i(this.points,function(a){if(a.drilldown&&a.dataLabel)a.dataLabel.attr({"class":"highcharts-drilldown-data-label"}).css(b).on("click",function(){a.doDrilldown()})})});var r,m=function(a){a.call(this);i(this.points,function(a){a.drilldown&&a.graphic&&a.graphic.attr({"class":"highcharts-drilldown-point"}).css({cursor:"pointer"})})};
-for(r in l)l[r].prototype.supportsDrilldown&&p(l[r].prototype,"drawTracker",m)})(Highcharts);
+(function(g){function t(a,b,d){return"rgba("+[Math.round(a[0]+(b[0]-a[0])*d),Math.round(a[1]+(b[1]-a[1])*d),Math.round(a[2]+(b[2]-a[2])*d),a[3]+(b[3]-a[3])*d].join(",")+")"}var u=function(){},o=g.getOptions(),i=g.each,p=g.extend,z=g.format,A=g.pick,q=g.wrap,l=g.Chart,n=g.seriesTypes,v=n.pie,m=n.column,w=HighchartsAdapter.fireEvent,x=HighchartsAdapter.inArray,r=[];p(o.lang,{drillUpText:"◁ Back to {series.name}"});o.drilldown={activeAxisLabelStyle:{cursor:"pointer",color:"#0d233a",fontWeight:"bold",
+textDecoration:"underline"},activeDataLabelStyle:{cursor:"pointer",color:"#0d233a",fontWeight:"bold",textDecoration:"underline"},animation:{duration:500},drillUpButton:{position:{align:"right",x:-10,y:10}}};g.SVGRenderer.prototype.Element.prototype.fadeIn=function(a){this.attr({opacity:0.1,visibility:"inherit"}).animate({opacity:A(this.newOpacity,1)},a||{duration:250})};l.prototype.addSeriesAsDrilldown=function(a,b){this.addSingleSeriesAsDrilldown(a,b);this.applyDrilldown()};l.prototype.addSingleSeriesAsDrilldown=
+function(a,b){var d=a.series,c=d.xAxis,f=d.yAxis,h;h=a.color||d.color;var e,y=[],g=[],k;k=d.levelNumber||0;b=p({color:h},b);e=x(a,d.points);i(d.chart.series,function(a){if(a.xAxis===c)y.push(a),g.push(a.userOptions),a.levelNumber=a.levelNumber||k});h={levelNumber:k,seriesOptions:d.userOptions,levelSeriesOptions:g,levelSeries:y,shapeArgs:a.shapeArgs,bBox:a.graphic.getBBox(),color:h,lowerSeriesOptions:b,pointOptions:d.options.data[e],pointIndex:e,oldExtremes:{xMin:c&&c.userMin,xMax:c&&c.userMax,yMin:f&&
+f.userMin,yMax:f&&f.userMax}};if(!this.drilldownLevels)this.drilldownLevels=[];this.drilldownLevels.push(h);h=h.lowerSeries=this.addSeries(b,!1);h.levelNumber=k+1;if(c)c.oldPos=c.pos,c.userMin=c.userMax=null,f.userMin=f.userMax=null;if(d.type===h.type)h.animate=h.animateDrilldown||u,h.options.animation=!0};l.prototype.applyDrilldown=function(){var a=this.drilldownLevels,b;if(a&&a.length>0)b=a[a.length-1].levelNumber,i(this.drilldownLevels,function(a){a.levelNumber===b&&i(a.levelSeries,function(a){a.levelNumber===
+b&&a.remove(!1)})});this.redraw();this.showDrillUpButton()};l.prototype.getDrilldownBackText=function(){var a=this.drilldownLevels;if(a&&a.length>0)return a=a[a.length-1],a.series=a.seriesOptions,z(this.options.lang.drillUpText,a)};l.prototype.showDrillUpButton=function(){var a=this,b=this.getDrilldownBackText(),d=a.options.drilldown.drillUpButton,c,f;this.drillUpButton?this.drillUpButton.attr({text:b}).align():(f=(c=d.theme)&&c.states,this.drillUpButton=this.renderer.button(b,null,null,function(){a.drillUp()},
+c,f&&f.hover,f&&f.select).attr({align:d.position.align,zIndex:9}).add().align(d.position,!1,d.relativeTo||"plotBox"))};l.prototype.drillUp=function(){for(var a=this,b=a.drilldownLevels,d=b[b.length-1].levelNumber,c=b.length,f=a.series,h=f.length,e,g,j,k,l=function(b){var c;i(f,function(a){a.userOptions===b&&(c=a)});c=c||a.addSeries(b,!1);if(c.type===g.type&&c.animateDrillupTo)c.animate=c.animateDrillupTo;b===e.seriesOptions&&(j=c)};c--;)if(e=b[c],e.levelNumber===d){b.pop();g=e.lowerSeries;if(!g.chart)for(;h--;)if(f[h].options.id===
+e.lowerSeriesOptions.id){g=f[h];break}g.xData=[];i(e.levelSeriesOptions,l);w(a,"drillup",{seriesOptions:e.seriesOptions});if(j.type===g.type)j.drilldownLevel=e,j.options.animation=a.options.drilldown.animation,g.animateDrillupFrom&&g.animateDrillupFrom(e);j.levelNumber=d;g.remove(!1);if(j.xAxis)k=e.oldExtremes,j.xAxis.setExtremes(k.xMin,k.xMax,!1),j.yAxis.setExtremes(k.yMin,k.yMax,!1)}this.redraw();this.drilldownLevels.length===0?this.drillUpButton=this.drillUpButton.destroy():this.drillUpButton.attr({text:this.getDrilldownBackText()}).align();
+r.length=[]};m.prototype.supportsDrilldown=!0;m.prototype.animateDrillupTo=function(a){if(!a){var b=this,d=b.drilldownLevel;i(this.points,function(a){a.graphic.hide();a.dataLabel&&a.dataLabel.hide();a.connector&&a.connector.hide()});setTimeout(function(){i(b.points,function(a,b){var h=b===(d&&d.pointIndex)?"show":"fadeIn",e=h==="show"?!0:void 0;a.graphic[h](e);if(a.dataLabel)a.dataLabel[h](e);if(a.connector)a.connector[h](e)})},Math.max(this.chart.options.drilldown.animation.duration-50,0));this.animate=
+u}};m.prototype.animateDrilldown=function(a){var b=this,d=this.chart.drilldownLevels,c=this.chart.drilldownLevels[this.chart.drilldownLevels.length-1].shapeArgs,f=this.chart.options.drilldown.animation;if(!a)i(d,function(a){if(b.userOptions===a.lowerSeriesOptions)c=a.shapeArgs}),c.x+=this.xAxis.oldPos-this.xAxis.pos,i(this.points,function(a){a.graphic&&a.graphic.attr(c).animate(a.shapeArgs,f);a.dataLabel&&a.dataLabel.fadeIn(f)}),this.animate=null};m.prototype.animateDrillupFrom=function(a){var b=
+this.chart.options.drilldown.animation,d=this.group,c=this;i(c.trackerGroups,function(a){if(c[a])c[a].on("mouseover")});delete this.group;i(this.points,function(c){var h=c.graphic,e=g.Color(c.color).rgba,i=g.Color(a.color).rgba,j=function(){h.destroy();d&&(d=d.destroy())};h&&(delete c.graphic,b?h.animate(a.shapeArgs,g.merge(b,{step:function(a,b){b.prop==="start"&&e.length===4&&i.length===4&&this.attr({fill:t(e,i,b.pos)})},complete:j})):(h.attr(a.shapeArgs),j()))})};v&&p(v.prototype,{supportsDrilldown:!0,
+animateDrillupTo:m.prototype.animateDrillupTo,animateDrillupFrom:m.prototype.animateDrillupFrom,animateDrilldown:function(a){var b=this.chart.drilldownLevels[this.chart.drilldownLevels.length-1],d=this.chart.options.drilldown.animation,c=b.shapeArgs,f=c.start,h=(c.end-f)/this.points.length,e=g.Color(b.color).rgba;if(!a)i(this.points,function(a,b){var i=g.Color(a.color).rgba;a.graphic.attr(g.merge(c,{start:f+b*h,end:f+(b+1)*h}))[d?"animate":"attr"](a.shapeArgs,g.merge(d,{step:function(a,b){b.prop===
+"start"&&e.length===4&&i.length===4&&this.attr({fill:t(e,i,b.pos)})}}))}),this.animate=null}});g.Point.prototype.doDrilldown=function(a){for(var b=this.series.chart,d=b.options.drilldown,c=(d.series||[]).length,f;c--&&!f;)d.series[c].id===this.drilldown&&x(this.drilldown,r)===-1&&(f=d.series[c],r.push(this.drilldown));w(b,"drilldown",{point:this,seriesOptions:f});f&&(a?b.addSingleSeriesAsDrilldown(this,f):b.addSeriesAsDrilldown(this,f))};q(g.Point.prototype,"init",function(a,b,d,c){var f=a.call(this,
+b,d,c),h=b.chart,e=(a=b.xAxis&&b.xAxis.ticks[c])&&a.label;if(f.drilldown){if(g.addEvent(f,"click",function(){f.doDrilldown()}),e){if(!e.basicStyles)e.basicStyles=g.merge(e.styles);e.addClass("highcharts-drilldown-axis-label").css(h.options.drilldown.activeAxisLabelStyle).on("click",function(){i(e.ddPoints,function(a){a.doDrilldown&&a.doDrilldown(!0)});h.applyDrilldown()});if(!e.ddPoints)e.ddPoints=[];e.ddPoints.push(f)}}else if(e&&e.basicStyles)e.styles={},e.css(e.basicStyles);return f});q(g.Series.prototype,
+"drawDataLabels",function(a){var b=this.chart.options.drilldown.activeDataLabelStyle;a.call(this);i(this.points,function(a){if(a.drilldown&&a.dataLabel)a.dataLabel.attr({"class":"highcharts-drilldown-data-label"}).css(b).on("click",function(){a.doDrilldown()})})});var s,o=function(a){a.call(this);i(this.points,function(a){a.drilldown&&a.graphic&&a.graphic.attr({"class":"highcharts-drilldown-point"}).css({cursor:"pointer"})})};for(s in n)n[s].prototype.supportsDrilldown&&q(n[s].prototype,"drawTracker",
+o)})(Highcharts);