funnel3d.js
7.9 KB
/*
Highcharts JS v7.2.0 (2019-09-03)
Highcharts funnel module
(c) 2010-2019 Kacper Madej
License: www.highcharts.com/license
*/
(function(h){"object"===typeof module&&module.exports?(h["default"]=h,module.exports=h):"function"===typeof define&&define.amd?define("highcharts/modules/funnel3d",["highcharts","highcharts/highcharts-3d","highcharts/modules/cylinder"],function(k){h(k);h.Highcharts=k;return h}):h("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(h){function k(d,h,J,k){d.hasOwnProperty(h)||(d[h]=k.apply(null,J))}h=h?h._modules:{};k(h,"modules/funnel3d.src.js",[h["parts/Globals.js"]],function(d){var h=d.charts,
k=d.color,K=d.error,E=d.extend,I=d.merge,C=d.pick,p=d.seriesType,L=d.seriesTypes,A=d.relativeLength,q=d.Renderer.prototype,M=q.cuboidPath;p("funnel3d","column",{center:["50%","50%"],width:"90%",neckWidth:"30%",height:"100%",neckHeight:"25%",reversed:!1,gradientForSides:!0,animation:!1,edgeWidth:0,colorByPoint:!0,showInLegend:!1,dataLabels:{align:"right",crop:!1,inside:!1,overflow:"allow"}},{bindAxes:function(){d.Series.prototype.bindAxes.apply(this,arguments);E(this.xAxis.options,{gridLineWidth:0,
lineWidth:0,title:null,tickPositions:[]});E(this.yAxis.options,{gridLineWidth:0,title:null,labels:{enabled:!1}})},translate3dShapes:d.noop,translate:function(){d.Series.prototype.translate.apply(this,arguments);var a=0,b=this.chart,c=this.options,g=c.reversed,t=c.ignoreHiddenPoint,e=b.plotWidth,F=b.plotHeight,f=0,h=c.center,v=A(h[0],e),r=A(h[1],F),k=A(c.width,e),m,u,l=A(c.height,F),q=A(c.neckWidth,e),p=A(c.neckHeight,F),B=r-l/2+l-p;e=this.data;var y,G,w,z,H,D,n;this.getWidthAt=u=function(b){var a=
r-l/2;return b>B||l===p?q:q+(k-q)*(1-(b-a)/(l-p))};this.center=[v,r,l];this.centerX=v;e.forEach(function(b){t&&!1===b.visible||(a+=b.y)});e.forEach(function(e){H=null;y=a?e.y/a:0;w=r-l/2+f*l;z=w+y*l;m=u(w);D=z-w;n={gradientForSides:C(e.options.gradientForSides,c.gradientForSides),x:v,y:w,height:D,width:m,z:1,top:{width:m}};m=u(z);n.bottom={fraction:y,width:m};w>=B?n.isCylinder=!0:z>B&&(H=z,m=u(B),z=B,n.bottom.width=m,n.middle={fraction:D?(B-w)/D:0,width:m});g&&(n.y=w=r+l/2-(f+y)*l,n.middle&&(n.middle.fraction=
1-(D?n.middle.fraction:0)),m=n.width,n.width=n.bottom.width,n.bottom.width=m);e.shapeArgs=E(e.shapeArgs,n);e.percentage=100*y;e.plotX=v;e.plotY=g?r+l/2-(f+y/2)*l:(w+(H||z))/2;G=d.perspective([{x:v,y:e.plotY,z:g?-(k-u(e.plotY))/2:-u(e.plotY)/2}],b,!0)[0];e.tooltipPos=[G.x,G.y];e.dlBoxRaw={x:v,width:u(e.plotY),y:w,bottom:n.height,fullWidth:k};t&&!1===e.visible||(f+=y)})},alignDataLabel:function(a,b,c){var g=a.dlBoxRaw,t=this.chart.inverted,e=a.plotY>C(this.translatedThreshold,this.yAxis.len),d=C(c.inside,
!!this.options.stacking),f={x:g.x,y:g.y,height:0};c.align=C(c.align,!t||d?"center":e?"right":"left");c.verticalAlign=C(c.verticalAlign,t||d?"middle":e?"top":"bottom");"top"!==c.verticalAlign&&(f.y+=g.bottom/("bottom"===c.verticalAlign?1:2));f.width=this.getWidthAt(f.y);this.options.reversed&&(f.width=g.fullWidth-f.width);d?f.x-=f.width/2:"left"===c.align?(c.align="right",f.x-=1.5*f.width):"right"===c.align?(c.align="left",f.x+=f.width/2):f.x-=f.width/2;a.dlBox=f;L.column.prototype.alignDataLabel.apply(this,
arguments)}},{shapeType:"funnel3d"});p=d.merge(q.elements3d.cuboid,{parts:"top bottom frontUpper backUpper frontLower backLower rightUpper rightLower".split(" "),mainParts:["top","bottom"],sideGroups:["upperGroup","lowerGroup"],sideParts:{upperGroup:["frontUpper","backUpper","rightUpper"],lowerGroup:["frontLower","backLower","rightLower"]},pathType:"funnel3d",opacitySetter:function(a){var b=this,c=b.parts,g=d.charts[b.renderer.chartIndex],t="group-opacity-"+a+"-"+g.index;b.parts=b.mainParts;b.singleSetterForParts("opacity",
a);b.parts=c;g.renderer.filterId||(g.renderer.definition({tagName:"filter",id:t,children:[{tagName:"feComponentTransfer",children:[{tagName:"feFuncA",type:"table",tableValues:"0 "+a}]}]}),b.sideGroups.forEach(function(a){b[a].attr({filter:"url(#"+t+")"})}),b.renderer.styledMode&&(g.renderer.definition({tagName:"style",textContent:".highcharts-"+t+" {filter:url(#"+t+")}"}),b.sideGroups.forEach(function(b){b.addClass("highcharts-"+t)})));return b},fillSetter:function(a){var b=this,c=k(a),g=c.rgba[3],
d={top:k(a).brighten(.1).get(),bottom:k(a).brighten(-.2).get()};1>g?(c.rgba[3]=1,c=c.get("rgb"),b.attr({opacity:g})):c=a;c.linearGradient||c.radialGradient||!b.gradientForSides||(c={linearGradient:{x1:0,x2:1,y1:1,y2:1},stops:[[0,k(a).brighten(-.2).get()],[.5,a],[1,k(a).brighten(-.2).get()]]});c.linearGradient?b.sideGroups.forEach(function(a){var e=b[a].gradientBox,f=c.linearGradient,g=I(c,{linearGradient:{x1:e.x+f.x1*e.width,y1:e.y+f.y1*e.height,x2:e.x+f.x2*e.width,y2:e.y+f.y2*e.height}});b.sideParts[a].forEach(function(b){d[b]=
g})}):(I(!0,d,{frontUpper:c,backUpper:c,rightUpper:c,frontLower:c,backLower:c,rightLower:c}),c.radialGradient&&b.sideGroups.forEach(function(a){var c=b[a].gradientBox,e=c.x+c.width/2,g=c.y+c.height/2,d=Math.min(c.width,c.height);b.sideParts[a].forEach(function(a){b[a].setRadialReference([e,g,d])})}));b.singleSetterForParts("fill",null,d);b.color=b.fill=a;c.linearGradient&&[b.frontLower,b.frontUpper].forEach(function(a){(a=(a=a.element)&&b.renderer.gradients[a.gradient])&&"userSpaceOnUse"!==a.attr("gradientUnits")&&
a.attr({gradientUnits:"userSpaceOnUse"})});return b},adjustForGradient:function(){var a=this,b;a.sideGroups.forEach(function(c){var g={x:Number.MAX_VALUE,y:Number.MAX_VALUE},d={x:-Number.MAX_VALUE,y:-Number.MAX_VALUE};a.sideParts[c].forEach(function(c){b=a[c].getBBox(!0);g={x:Math.min(g.x,b.x),y:Math.min(g.y,b.y)};d={x:Math.max(d.x,b.x+b.width),y:Math.max(d.y,b.y+b.height)}});a[c].gradientBox={x:g.x,width:d.x-g.x,y:g.y,height:d.y-g.y}})},zIndexSetter:function(){this.finishedOnAdd&&this.adjustForGradient();
return this.renderer.Element.prototype.zIndexSetter.apply(this,arguments)},onAdd:function(){this.adjustForGradient();this.finishedOnAdd=!0}});q.elements3d.funnel3d=p;q.funnel3d=function(a){var b=this.element3d("funnel3d",a),c=this.styledMode,d={"stroke-width":1,stroke:"none"};b.upperGroup=this.g("funnel3d-upper-group").attr({zIndex:b.frontUpper.zIndex}).add(b);[b.frontUpper,b.backUpper,b.rightUpper].forEach(function(a){c||a.attr(d);a.add(b.upperGroup)});b.lowerGroup=this.g("funnel3d-lower-group").attr({zIndex:b.frontLower.zIndex}).add(b);
[b.frontLower,b.backLower,b.rightLower].forEach(function(a){c||a.attr(d);a.add(b.lowerGroup)});b.gradientForSides=a.gradientForSides;return b};q.funnel3dPath=function(a){this.getCylinderEnd||K("A required Highcharts module is missing: cylinder.js",!0,h[this.chartIndex]);var b=h[this.chartIndex],c=a.alphaCorrection=90-Math.abs(b.options.chart.options3d.alpha%180-90),g=M.call(this,d.merge(a,{depth:a.width,width:(a.width+a.bottom.width)/2})),k=g.isTop,e=!g.isFront,q=!!a.middle,f=this.getCylinderEnd(b,
d.merge(a,{x:a.x-a.width/2,z:a.z-a.width/2,alphaCorrection:c})),p=a.bottom.width,v=d.merge(a,{width:p,x:a.x-p/2,z:a.z-p/2,alphaCorrection:c}),r=this.getCylinderEnd(b,v,!0),x=p,m=v,u=r,l=r;q&&(x=a.middle.width,m=d.merge(a,{y:a.y+a.middle.fraction*a.height,width:x,x:a.x-x/2,z:a.z-x/2}),u=this.getCylinderEnd(b,m,!1),l=this.getCylinderEnd(b,m,!1));g={top:f,bottom:r,frontUpper:this.getCylinderFront(f,u),zIndexes:{group:g.zIndexes.group,top:0!==k?0:3,bottom:1!==k?0:3,frontUpper:e?2:1,backUpper:e?1:2,rightUpper:e?
2:1}};g.backUpper=this.getCylinderBack(f,u);f=1!==Math.min(x,a.width)/Math.max(x,a.width);g.rightUpper=this.getCylinderFront(this.getCylinderEnd(b,d.merge(a,{x:a.x-a.width/2,z:a.z-a.width/2,alphaCorrection:f?-c:0}),!1),this.getCylinderEnd(b,d.merge(m,{alphaCorrection:f?-c:0}),!q));q&&(f=1!==Math.min(x,p)/Math.max(x,p),d.merge(!0,g,{frontLower:this.getCylinderFront(l,r),backLower:this.getCylinderBack(l,r),rightLower:this.getCylinderFront(this.getCylinderEnd(b,d.merge(v,{alphaCorrection:f?-c:0}),!0),
this.getCylinderEnd(b,d.merge(m,{alphaCorrection:f?-c:0}),!1)),zIndexes:{frontLower:e?2:1,backLower:e?1:2,rightLower:e?1:2}}));return g}});k(h,"masters/modules/funnel3d.src.js",[],function(){})});
//# sourceMappingURL=funnel3d.js.map