highcharts
Version:
JavaScript charting framework
15 lines • 12 kB
JavaScript
/**
* Highcharts JS v13.0.1 (2026-08-17)
* @module highcharts/modules/funnel3d
* @requires highcharts
* @requires highcharts/highcharts-3d
* @requires highcharts/modules/cylinder
*
* Highcharts funnel module
*
* (c) 2010-2026 Highsoft AS
* Author: Kacper Madej
*
* A commercial license may be required depending on use,
* see www.highcharts.com/license
*/import*as t from"../highcharts.js";let e={};e.n=t=>{let i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},e.d=(t,i)=>{if(Array.isArray(i))for(var r=0;r<i.length;){var s=i[r++],o=i[r++];e.o(t,s)?0===o&&r++:0===o?Object.defineProperty(t,s,{enumerable:!0,value:i[r++]}):Object.defineProperty(t,s,{enumerable:!0,get:o})}else for(var s in i)e.o(i,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:i[s]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=t.default;var r=e.n(i);let s=t.default.SVGRenderer;var o=e.n(s);let n=t.default.Color;var d=e.n(n);let h=t.default.SVGElement;var a=e.n(h);let{parse:l}=d();class p extends a(){constructor(){super(...arguments),this.parts=["front","top","side"],this.pathType="cuboid"}initArgs(t){let e=this.renderer,i=e[this.pathType+"Path"](t),r=i.zIndexes;for(let t of this.parts){let s={class:"highcharts-3d-"+t,zIndex:r[t]||0};e.styledMode&&("top"===t?s.filter="url(#highcharts-brighter)":"side"===t&&(s.filter="url(#highcharts-darker)")),this[t]=e.path(i[t]).attr(s).add(this)}this.attr({"stroke-linejoin":"round",zIndex:r.group}),this.forcedSides=i.forcedSides}singleSetterForParts(t,e,i,r,s,o){let n={},d=[null,null,r||"attr",s,o],h=i?.zIndexes;if(i){for(let e of(h?.group&&this.attr({zIndex:h.group}),Object.keys(i)))n[e]={},n[e][t]=i[e],h&&(n[e].zIndex=i.zIndexes[e]||0);d[1]=n}else n[t]=e,d[0]=n;return this.processParts.apply(this,d)}processParts(t,e,r,s,o){for(let n of this.parts)e&&(t=(0,i.pick)(e[n],!1)),!1!==t&&this[n][r](t,s,o);return this}destroy(){return this.processParts(null,null,"destroy"),super.destroy()}attr(t,e,r,s){if("string"==typeof t&&void 0!==e){let i=t;(t={})[i]=e}return t.shapeArgs||(0,i.defined)(t.x)?this.singleSetterForParts("d",null,this.renderer[this.pathType+"Path"](t.shapeArgs||t)):super.attr(t,void 0,r,s)}animate(t,e,r){if((0,i.defined)(t.x)&&(0,i.defined)(t.y)){let i=this.renderer[this.pathType+"Path"](t),s=i.forcedSides;this.singleSetterForParts("d",null,i,"animate",e,r),this.attr({zIndex:i.zIndexes.group}),s!==this.forcedSides&&(this.forcedSides=s,this.renderer.styledMode||this.fillSetter(this.fill))}else super.animate(t,e,r);return this}fillSetter(t){return this.forcedSides=this.forcedSides||[],this.singleSetterForParts("fill",null,{front:t,top:l(t).brighten(this.forcedSides.indexOf("top")>=0?0:.1).get(),side:l(t).brighten(this.forcedSides.indexOf("side")>=0?0:-.1).get()}),this.color=this.fill=t,this}}p.types={base:p,cuboid:p};let g=p,{parse:c}=d(),{charts:f}=r(),u=class extends g{constructor(){super(...arguments),this.mainParts=["top","bottom"],this.parts=["top","bottom","frontUpper","backUpper","frontLower","backLower","rightUpper","rightLower"],this.sideGroups=["upperGroup","lowerGroup"],this.sideParts={upperGroup:["frontUpper","backUpper","rightUpper"],lowerGroup:["frontLower","backLower","rightLower"]},this.pathType="funnel3d"}opacitySetter(t){let e=parseFloat(t),i=this.parts,r=f[this.renderer.chartIndex],s="group-opacity-"+e+"-"+r.index;if(this.parts=this.mainParts,this.singleSetterForParts("opacity",e),this.parts=i,!r.renderer.filterId){for(let t of(r.renderer.definition({tagName:"filter",attributes:{id:s},children:[{tagName:"feComponentTransfer",children:[{tagName:"feFuncA",attributes:{type:"table",tableValues:"0 "+e}}]}]}),this.sideGroups))this[t].attr({filter:"url(#"+s+")"});if(this.renderer.styledMode)for(let t of(r.renderer.definition({tagName:"style",textContent:".highcharts-"+s+" {filter:url(#"+s+")}"}),this.sideGroups))this[t].addClass("highcharts-"+s)}return this}fillSetter(t){let e=c(t),r=e.rgba[3],s={top:c(t).brighten(.1).get(),bottom:c(t).brighten(-.2).get()};if(r<1?(e.rgba[3]=1,e=e.get("rgb"),this.attr({opacity:r})):e=t,e.linearGradient||e.radialGradient||!this.gradientForSides||(e={linearGradient:{x1:0,x2:1,y1:1,y2:1},stops:[[0,c(t).brighten(-.2).get()],[.5,t],[1,c(t).brighten(-.2).get()]]}),e.linearGradient)for(let t of this.sideGroups){let r=this[t].gradientBox,o=e.linearGradient,n=(0,i.merge)(e,{linearGradient:{x1:r.x+o.x1*r.width,y1:r.y+o.y1*r.height,x2:r.x+o.x2*r.width,y2:r.y+o.y2*r.height}});for(let e of this.sideParts[t])s[e]=n}else if((0,i.merge)(!0,s,{frontUpper:e,backUpper:e,rightUpper:e,frontLower:e,backLower:e,rightLower:e}),e.radialGradient)for(let t of this.sideGroups){let e=this[t].gradientBox,i=e.x+e.width/2,r=e.y+e.height/2,s=Math.min(e.width,e.height);for(let e of this.sideParts[t])this[e].setRadialReference([i,r,s])}if(this.singleSetterForParts("fill",null,s),this.color=this.fill=t,e.linearGradient)for(let t of[this.frontLower,this.frontUpper]){let e=t.element,i=e&&this.renderer.gradients[e.gradient];i&&"userSpaceOnUse"!==i.attr("gradientUnits")&&i.attr({gradientUnits:"userSpaceOnUse"})}return this}adjustForGradient(){let t;for(let e of this.sideGroups){let i={x:Number.MAX_VALUE,y:Number.MAX_VALUE},r={x:-Number.MAX_VALUE,y:-Number.MAX_VALUE};for(let s of this.sideParts[e])t=this[s].getBBox(!0),i={x:Math.min(i.x,t.x),y:Math.min(i.y,t.y)},r={x:Math.max(r.x,t.x+t.width),y:Math.max(r.y,t.y+t.height)};this[e].gradientBox={x:i.x,width:r.x-i.x,y:i.y,height:r.y-i.y}}}zIndexSetter(){return this.finishedOnAdd&&this.adjustForGradient(),this.renderer.Element.prototype.zIndexSetter.apply(this,arguments)}onAdd(){this.adjustForGradient(),this.finishedOnAdd=!0}},{charts:y}=r();function x(t){let e=this.element3d("funnel3d",t),i=this.styledMode,r={"stroke-width":1,stroke:"none"};for(let t of(e.upperGroup=this.g("funnel3d-upper-group").attr({zIndex:e.frontUpper.zIndex}).add(e),[e.frontUpper,e.backUpper,e.rightUpper]))i||t.attr(r),t.add(e.upperGroup);for(let t of(e.lowerGroup=this.g("funnel3d-lower-group").attr({zIndex:e.frontLower.zIndex}).add(e),[e.frontLower,e.backLower,e.rightLower]))i||t.attr(r),t.add(e.lowerGroup);return e.gradientForSides=t.gradientForSides,e}function m(t){this.getCylinderEnd||(0,i.error)("A required Highcharts module is missing: cylinder.js",!0,y[this.chartIndex]);let e=y[this.chartIndex],r=t.alphaCorrection=90-Math.abs(e.options.chart.options3d.alpha%180-90),s=this.cuboidPath.call(this,(0,i.merge)(t,{depth:t.width,width:(t.width+t.bottom.width)/2})),o=s.isTop,n=!s.isFront,d=!!t.middle,h=this.getCylinderEnd(e,(0,i.merge)(t,{x:t.x-t.width/2,z:t.z-t.width/2,alphaCorrection:r})),a=t.bottom.width,l=(0,i.merge)(t,{width:a,x:t.x-a/2,z:t.z-a/2,alphaCorrection:r}),p=this.getCylinderEnd(e,l,!0),g=a,c=l,f=p,u=p,x;d&&(g=t.middle.width,c=(0,i.merge)(t,{y:t.y+t.middle.fraction*t.height,width:g,x:t.x-g/2,z:t.z-g/2}),f=this.getCylinderEnd(e,c,!1),u=this.getCylinderEnd(e,c,!1));let m={top:h,bottom:p,frontUpper:this.getCylinderFront(h,f),zIndexes:{group:s.zIndexes.group,top:3*(0===o),bottom:3*(1===o),frontUpper:n?2:1,backUpper:n?1:2,rightUpper:n?2:1}};return m.backUpper=this.getCylinderBack(h,f),x=Math.min(g,t.width)/Math.max(g,t.width)!=1,m.rightUpper=this.getCylinderFront(this.getCylinderEnd(e,(0,i.merge)(t,{x:t.x-t.width/2,z:t.z-t.width/2,alphaCorrection:x?-r:0}),!1),this.getCylinderEnd(e,(0,i.merge)(c,{alphaCorrection:x?-r:0}),!d)),d&&(x=Math.min(g,a)/Math.max(g,a)!=1,(0,i.merge)(!0,m,{frontLower:this.getCylinderFront(u,p),backLower:this.getCylinderBack(u,p),rightLower:this.getCylinderFront(this.getCylinderEnd(e,(0,i.merge)(l,{alphaCorrection:x?-r:0}),!0),this.getCylinderEnd(e,(0,i.merge)(c,{alphaCorrection:x?-r:0}),!1)),zIndexes:{frontLower:n?2:1,backLower:n?1:2,rightLower:n?1:2}})),m}let w=t.default.SeriesRegistry;var b=e.n(w);let{seriesTypes:{column:z}}=b();class A extends z.prototype.pointClass{}(0,i.extend)(A.prototype,{shapeType:"funnel3d"});let{deg2rad:k}=r();function v(t,e,r,s){let o=e.options.chart.options3d,n=(0,i.pick)(s,!!r&&e.inverted),d={x:e.plotWidth/2,y:e.plotHeight/2,z:o.depth/2,vd:(0,i.pick)(o.depth,1)*(0,i.pick)(o.viewDistance,0)},h=e.scale3d||1,a=k*o.beta*(n?-1:1),l=k*o.alpha*(n?-1:1),p={cosA:Math.cos(l),cosB:Math.cos(-a),sinA:Math.sin(l),sinB:Math.sin(-a)};return r||(d.x+=e.plotLeft,d.y+=e.plotTop),t.map(function(t){var e,i,r;let s=(e=(n?t.y:t.x)-d.x,i=(n?t.x:t.y)-d.y,r=(t.z||0)-d.z,{x:p.cosB*e-p.sinB*r,y:-p.sinA*p.sinB*e+p.cosA*i-p.cosB*p.sinA*r,z:p.cosA*p.sinB*e+p.sinA*i+p.cosA*p.cosB*r}),o=L(s,d,d.vd);return o.x=o.x*h+d.x,o.y=o.y*h+d.y,o.z=s.z*h+d.z,{x:n?o.y:o.x,y:n?o.x:o.y,z:o.z}})}function L(t,e,i){let r=i>0&&i<1/0?i/(t.z+e.z+i):1;return{x:t.x*r,y:t.y*r}}function S(t){let e=0,i,r;for(i=0;i<t.length;i++)r=(i+1)%t.length,e+=t[i].x*t[r].y-t[r].x*t[i].y;return e/2}let{noop:C}=r(),{perspective:P}={perspective:v,perspective3D:L,pointCameraDistance:function(t,e){let r=e.options.chart.options3d,s={x:e.plotWidth/2,y:e.plotHeight/2,z:(0,i.pick)(r.depth,1)*(0,i.pick)(r.viewDistance,0)+r.depth};return Math.sqrt(Math.pow(s.x-(0,i.pick)(t.plotX,t.x),2)+Math.pow(s.y-(0,i.pick)(t.plotY,t.y),2)+Math.pow(s.z-(0,i.pick)(t.plotZ,t.z),2))},shapeArea:S,shapeArea3D:function(t,e,i){return S(v(t,e,i))}},{series:U,seriesTypes:{column:G}}=b();class M extends G{alignDataLabel(t,e,r){let s=t.dlBoxRaw,o=this.chart.inverted,n=t.plotY>(0,i.pick)(this.translatedThreshold,this.yAxis.len),d=(0,i.pick)(r.inside,!!this.options.stacking),h={x:s.x,y:s.y,height:0};r.align=(0,i.pick)(r.align,!o||d?"center":n?"right":"left"),r.verticalAlign=(0,i.pick)(r.verticalAlign,o||d?"middle":n?"top":"bottom"),"top"!==r.verticalAlign&&(h.y+=s.bottom/("bottom"===r.verticalAlign?1:2)),h.width=this.getWidthAt(h.y),this.options.reversed&&(h.width=s.fullWidth-h.width),d?h.x-=h.width/2:"left"===r.align?(r.align="right",h.x-=1.5*h.width):"right"===r.align?(r.align="left",h.x+=h.width/2):h.x-=h.width/2,t.dlBox=h,G.prototype.alignDataLabel.apply(this,arguments)}bindAxes(){U.prototype.bindAxes.apply(this,arguments),(0,i.extend)(this.xAxis.options,{gridLineWidth:0,lineWidth:0,title:void 0,tickPositions:[]}),(0,i.merge)(!0,this.yAxis.options,{gridLineWidth:0,title:void 0,labels:{enabled:!1}})}translate(){U.prototype.translate.apply(this,arguments);let t=this.chart,e=this.options,r=e.reversed,s=e.ignoreHiddenPoint,o=t.plotWidth,n=t.plotHeight,d=e.center,h=(0,i.relativeLength)(d[0],o),a=(0,i.relativeLength)(d[1],n),l=(0,i.relativeLength)(e.width,o),p=(0,i.relativeLength)(e.height,n),g=(0,i.relativeLength)(e.neckWidth,o),c=(0,i.relativeLength)(e.neckHeight,n),f=a-p/2+p-c,u=this.points,y=0,x=0,m,w,b,z,A,k,v,L,S;for(let t of(this.getWidthAt=w=function(t){return t>f||p===c?g:g+(l-g)*(1-(t-(a-p/2))/(p-c))},this.center=[h,a,p],this.centerX=h,u))s&&!1===t.visible||(y+=t.y);for(let o of u)v=null,b=y?o.y/y:0,k=(A=a-p/2+x*p)+b*p,m=w(A),L=k-A,(S={gradientForSides:(0,i.pick)(o.options.gradientForSides,e.gradientForSides),x:h,y:A,height:L,width:m,z:1,top:{width:m}}).bottom={fraction:b,width:m=w(k)},A>=f?S.isCylinder=!0:k>f&&(v=k,m=w(f),k=f,S.bottom.width=m,S.middle={fraction:L?(f-A)/L:0,width:m}),r&&(S.y=A=a+p/2-(x+b)*p,S.middle&&(S.middle.fraction=1-(L?S.middle.fraction:0)),m=S.width,S.width=S.bottom.width,S.bottom.width=m),o.shapeArgs=(0,i.extend)(o.shapeArgs,S),o.percentage=100*b,o.plotX=h,r?o.plotY=a+p/2-(x+b/2)*p:o.plotY=(A+(v||k))/2,z=P([{x:h,y:o.plotY,z:r?-(l-w(o.plotY))/2:-w(o.plotY)/2}],t,!0)[0],o.tooltipPos=[z.x,z.y],o.dlBoxRaw={x:h,width:w(o.plotY),y:A,bottom:S.height||0,fullWidth:l},s&&!1===o.visible||(x+=b)}}M.compose=function(t){let e=t.prototype;e.funnel3d||(e.Element3D.types.funnel3d=u,(0,i.extend)(e,{funnel3d:x,funnel3dPath:m}))},M.defaultOptions=(0,i.merge)(G.defaultOptions,{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"}}),(0,i.extend)(M.prototype,{pointClass:A,translate3dShapes:C}),b().registerSeriesType("funnel3d",M),M.compose(o());let F=r();export{F as default};