highcharts
Version:
JavaScript charting framework
15 lines • 10.5 kB
JavaScript
/**
* Highcharts JS v12.6.0 (2026-04-13)
* @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";var e={};e.n=t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},e.d=(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r=t.default;var i=e.n(r);let o=t.default.Color;var n=e.n(o);let s=t.default.RendererRegistry;var a=e.n(s);let{doc:d,win:h}=i();function l(t,e){let r;for(r in t||(t={}),e)t[r]=e[r];return t}function p(t){return c(t)&&"number"==typeof t.nodeType}function c(t,e){let r;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(r=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==r)}function g(t,...e){let r,i=[t,...e],o={},n=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,r){for(let r in t)Object.hasOwnProperty.call(t,r)&&e.call((0,t[r]),t[r],r,t)}(e,function(r,i){if("__proto__"!==i&&"constructor"!==i){let o;!c(r,!0)||(o=r?.constructor,c(r,!0)&&!p(r)&&o?.name&&"Object"!==o.name)||p(r)?t[i]=e[i]:t[i]=n(t[i]||{},r)}}),t};!0===t&&(o=i[1],i=Array.prototype.slice.call(i,2));let s=i.length;for(r=0;r<s;r++)o=n(o,i[r]);return o}function f(){let t=arguments,e=t.length;for(let r=0;r<e;r++){let e=t[r];if(null!=e)return e}}function y(t,e,r){return/%$/.test(t)?e*parseFloat(t)/100+(r||0):parseFloat(t)}Array.prototype.find;let{parse:u}=n(),{charts:x}=i(),{Element3D:w}=a().getRendererType().prototype,b=class extends w{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),r=this.parts,i=x[this.renderer.chartIndex],o="group-opacity-"+e+"-"+i.index;if(this.parts=this.mainParts,this.singleSetterForParts("opacity",e),this.parts=r,!i.renderer.filterId){for(let t of(i.renderer.definition({tagName:"filter",attributes:{id:o},children:[{tagName:"feComponentTransfer",children:[{tagName:"feFuncA",attributes:{type:"table",tableValues:"0 "+e}}]}]}),this.sideGroups))this[t].attr({filter:"url(#"+o+")"});if(this.renderer.styledMode)for(let t of(i.renderer.definition({tagName:"style",textContent:".highcharts-"+o+" {filter:url(#"+o+")}"}),this.sideGroups))this[t].addClass("highcharts-"+o)}return this}fillSetter(t){let e=u(t),r=e.rgba[3],i={top:u(t).brighten(.1).get(),bottom:u(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,u(t).brighten(-.2).get()],[.5,t],[1,u(t).brighten(-.2).get()]]}),e.linearGradient)for(let t of this.sideGroups){let r=this[t].gradientBox,o=e.linearGradient,n=g(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])i[e]=n}else if(g(!0,i,{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,r=e.x+e.width/2,i=e.y+e.height/2,o=Math.min(e.width,e.height);for(let e of this.sideParts[t])this[e].setRadialReference([r,i,o])}if(this.singleSetterForParts("fill",null,i),this.color=this.fill=t,e.linearGradient)for(let t of[this.frontLower,this.frontUpper]){let e=t.element,r=e&&this.renderer.gradients[e.gradient];r&&"userSpaceOnUse"!==r.attr("gradientUnits")&&r.attr({gradientUnits:"userSpaceOnUse"})}return this}adjustForGradient(){let t;for(let e of this.sideGroups){let r={x:Number.MAX_VALUE,y:Number.MAX_VALUE},i={x:-Number.MAX_VALUE,y:-Number.MAX_VALUE};for(let o of this.sideParts[e])t=this[o].getBBox(!0),r={x:Math.min(r.x,t.x),y:Math.min(r.y,t.y)},i={x:Math.max(i.x,t.x+t.width),y:Math.max(i.y,t.y+t.height)};this[e].gradientBox={x:r.x,width:i.x-r.x,y:r.y,height:i.y-r.y}}}zIndexSetter(){return this.finishedOnAdd&&this.adjustForGradient(),this.renderer.Element.prototype.zIndexSetter.apply(this,arguments)}onAdd(){this.adjustForGradient(),this.finishedOnAdd=!0}},{charts:m}=i();function A(t){let e=this.element3d("funnel3d",t),r=this.styledMode,i={"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]))r||t.attr(i),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]))r||t.attr(i),t.add(e.lowerGroup);return e.gradientForSides=t.gradientForSides,e}function z(t){this.getCylinderEnd||(0,r.error)("A required Highcharts module is missing: cylinder.js",!0,m[this.chartIndex]);let e=m[this.chartIndex],i=t.alphaCorrection=90-Math.abs(e.options.chart.options3d.alpha%180-90),o=this.cuboidPath.call(this,g(t,{depth:t.width,width:(t.width+t.bottom.width)/2})),n=o.isTop,s=!o.isFront,a=!!t.middle,d=this.getCylinderEnd(e,g(t,{x:t.x-t.width/2,z:t.z-t.width/2,alphaCorrection:i})),h=t.bottom.width,l=g(t,{width:h,x:t.x-h/2,z:t.z-h/2,alphaCorrection:i}),p=this.getCylinderEnd(e,l,!0),c=h,f=l,y=p,u=p,x;a&&(c=t.middle.width,f=g(t,{y:t.y+t.middle.fraction*t.height,width:c,x:t.x-c/2,z:t.z-c/2}),y=this.getCylinderEnd(e,f,!1),u=this.getCylinderEnd(e,f,!1));let w={top:d,bottom:p,frontUpper:this.getCylinderFront(d,y),zIndexes:{group:o.zIndexes.group,top:3*(0===n),bottom:3*(1===n),frontUpper:s?2:1,backUpper:s?1:2,rightUpper:s?2:1}};return w.backUpper=this.getCylinderBack(d,y),x=Math.min(c,t.width)/Math.max(c,t.width)!=1,w.rightUpper=this.getCylinderFront(this.getCylinderEnd(e,g(t,{x:t.x-t.width/2,z:t.z-t.width/2,alphaCorrection:x?-i:0}),!1),this.getCylinderEnd(e,g(f,{alphaCorrection:x?-i:0}),!a)),a&&(x=Math.min(c,h)/Math.max(c,h)!=1,g(!0,w,{frontLower:this.getCylinderFront(u,p),backLower:this.getCylinderBack(u,p),rightLower:this.getCylinderFront(this.getCylinderEnd(e,g(l,{alphaCorrection:x?-i:0}),!0),this.getCylinderEnd(e,g(f,{alphaCorrection:x?-i:0}),!1)),zIndexes:{frontLower:s?2:1,backLower:s?1:2,rightLower:s?1:2}})),w}let L=t.default.SeriesRegistry;var C=e.n(L);let{seriesTypes:{column:U}}=C();class v extends U.prototype.pointClass{}l(v.prototype,{shapeType:"funnel3d"});let{deg2rad:G}=i();function M(t,e,r,i){let o=e.options.chart.options3d,n=f(i,!!r&&e.inverted),s={x:e.plotWidth/2,y:e.plotHeight/2,z:o.depth/2,vd:f(o.depth,1)*f(o.viewDistance,0)},a=e.scale3d||1,d=G*o.beta*(n?-1:1),h=G*o.alpha*(n?-1:1),l={cosA:Math.cos(h),cosB:Math.cos(-d),sinA:Math.sin(h),sinB:Math.sin(-d)};return r||(s.x+=e.plotLeft,s.y+=e.plotTop),t.map(function(t){var e,r,i;let o=(e=(n?t.y:t.x)-s.x,r=(n?t.x:t.y)-s.y,i=(t.z||0)-s.z,{x:l.cosB*e-l.sinB*i,y:-l.sinA*l.sinB*e+l.cosA*r-l.cosB*l.sinA*i,z:l.cosA*l.sinB*e+l.sinA*r+l.cosA*l.cosB*i}),d=k(o,s,s.vd);return d.x=d.x*a+s.x,d.y=d.y*a+s.y,d.z=o.z*a+s.z,{x:n?d.y:d.x,y:n?d.x:d.y,z:d.z}})}function k(t,e,r){let i=r>0&&r<1/0?r/(t.z+e.z+r):1;return{x:t.x*i,y:t.y*i}}function F(t){let e=0,r,i;for(r=0;r<t.length;r++)i=(r+1)%t.length,e+=t[r].x*t[i].y-t[i].x*t[r].y;return e/2}let{noop:B}=i(),{perspective:S}={perspective:M,perspective3D:k,pointCameraDistance:function(t,e){let r=e.options.chart.options3d,i={x:e.plotWidth/2,y:e.plotHeight/2,z:f(r.depth,1)*f(r.viewDistance,0)+r.depth};return Math.sqrt(Math.pow(i.x-f(t.plotX,t.x),2)+Math.pow(i.y-f(t.plotY,t.y),2)+Math.pow(i.z-f(t.plotZ,t.z),2))},shapeArea:F,shapeArea3D:function(t,e,r){return F(M(t,e,r))}},{series:P,seriesTypes:{column:E}}=C();class I extends E{alignDataLabel(t,e,r){let i=t.dlBoxRaw,o=this.chart.inverted,n=t.plotY>f(this.translatedThreshold,this.yAxis.len),s=f(r.inside,!!this.options.stacking),a={x:i.x,y:i.y,height:0};r.align=f(r.align,!o||s?"center":n?"right":"left"),r.verticalAlign=f(r.verticalAlign,o||s?"middle":n?"top":"bottom"),"top"!==r.verticalAlign&&(a.y+=i.bottom/("bottom"===r.verticalAlign?1:2)),a.width=this.getWidthAt(a.y),this.options.reversed&&(a.width=i.fullWidth-a.width),s?a.x-=a.width/2:"left"===r.align?(r.align="right",a.x-=1.5*a.width):"right"===r.align?(r.align="left",a.x+=a.width/2):a.x-=a.width/2,t.dlBox=a,E.prototype.alignDataLabel.apply(this,arguments)}bindAxes(){P.prototype.bindAxes.apply(this,arguments),l(this.xAxis.options,{gridLineWidth:0,lineWidth:0,title:void 0,tickPositions:[]}),g(!0,this.yAxis.options,{gridLineWidth:0,title:void 0,labels:{enabled:!1}})}translate(){P.prototype.translate.apply(this,arguments);let t=this.chart,e=this.options,r=e.reversed,i=e.ignoreHiddenPoint,o=t.plotWidth,n=t.plotHeight,s=e.center,a=y(s[0],o),d=y(s[1],n),h=y(e.width,o),p=y(e.height,n),c=y(e.neckWidth,o),g=y(e.neckHeight,n),u=d-p/2+p-g,x=this.points,w=0,b=0,m,A,z,L,C,U,v,G,M;for(let t of(this.getWidthAt=A=function(t){return t>u||p===g?c:c+(h-c)*(1-(t-(d-p/2))/(p-g))},this.center=[a,d,p],this.centerX=a,x))i&&!1===t.visible||(w+=t.y);for(let o of x)v=null,z=w?o.y/w:0,U=(C=d-p/2+b*p)+z*p,m=A(C),G=U-C,(M={gradientForSides:f(o.options.gradientForSides,e.gradientForSides),x:a,y:C,height:G,width:m,z:1,top:{width:m}}).bottom={fraction:z,width:m=A(U)},C>=u?M.isCylinder=!0:U>u&&(v=U,m=A(u),U=u,M.bottom.width=m,M.middle={fraction:G?(u-C)/G:0,width:m}),r&&(M.y=C=d+p/2-(b+z)*p,M.middle&&(M.middle.fraction=1-(G?M.middle.fraction:0)),m=M.width,M.width=M.bottom.width,M.bottom.width=m),o.shapeArgs=l(o.shapeArgs,M),o.percentage=100*z,o.plotX=a,r?o.plotY=d+p/2-(b+z/2)*p:o.plotY=(C+(v||U))/2,L=S([{x:a,y:o.plotY,z:r?-(h-A(o.plotY))/2:-A(o.plotY)/2}],t,!0)[0],o.tooltipPos=[L.x,L.y],o.dlBoxRaw={x:a,width:A(o.plotY),y:C,bottom:M.height||0,fullWidth:h},i&&!1===o.visible||(b+=z)}}I.compose=function(t){let e=t.prototype;e.funnel3d||(e.Element3D.types.funnel3d=b,l(e,{funnel3d:A,funnel3dPath:z}))},I.defaultOptions=g(E.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"}}),l(I.prototype,{pointClass:v,translate3dShapes:B}),C().registerSeriesType("funnel3d",I),I.compose(a().getRendererType());let j=i();export{j as default};