UNPKG

highcharts

Version:
13 lines 7.7 kB
/** * Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/funnel * @requires highcharts * * Highcharts funnel module * * (c) 2010-2026 Highsoft AS * Author: Torstein Hønsi * * 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 n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},e.d=(t,n)=>{for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let n=t.default;var a=e.n(n);let{doc:r,win:i}=a();function o(t,e){let n;for(n in t||(t={}),e)t[n]=e[n];return t}function s(t){return d(t)&&"number"==typeof t.nodeType}function l(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function d(t,e){return!!t&&"object"==typeof t&&(!e||!l(t))}function c(t,...e){let n,a=[t,...e],r={},i=function(t,e){return"object"!=typeof t&&(t={}),h(e,function(n,a){if("__proto__"!==a&&"constructor"!==a){let r;!d(n,!0)||(r=n?.constructor,d(n,!0)&&!s(n)&&r?.name&&"Object"!==r.name)||s(n)?t[a]=e[a]:t[a]=i(t[a]||{},n)}}),t};!0===t&&(r=a[1],a=Array.prototype.slice.call(a,2));let o=a.length;for(n=0;n<o;n++)r=i(r,a[n]);return r}function h(t,e,n){for(let a in t)Object.hasOwnProperty.call(t,a)&&e.call(n||t[a],t[a],a,t)}function p(t,e,n){return/%$/.test(t)?e*parseFloat(t)/100+(n||0):parseFloat(t)}Array.prototype.find;let{defaultOptions:u}=a(),{noop:f}=a(),y={radius:0,scope:"stack",where:void 0};function g(t,e){return d(t)||(t={radius:t||0}),c(y,e,t)}let b=t.default.SeriesRegistry;var x=e.n(b);let{composed:v,noop:L}=a(),{column:m,pie:P}=x().seriesTypes,E=x().series.prototype.alignDataLabel;function M(t,e){return/%$/.test(t)?e*parseInt(t,10)/100:parseInt(t,10)}class O extends P{alignDataLabel(t,e,n,a,r){let i=t.series,o=i.options.reversed,s=t.dlBox||t.shapeArgs,{align:l,padding:d=0,verticalAlign:c}=n,h=((i.options||{}).dataLabels||{}).inside,p=i.center[1],u=t.plotY||0,f=e.height??e.getBBox().height,y=i.getWidthAt((o?2*p-u:u)-s.height/2+f),g="middle"===c?(s.topWidth-s.bottomWidth)/4:(y-s.bottomWidth)/2,b=s.y,x=s.x;"middle"===c?b=s.y-s.height/2+f/2:"top"===c&&(b=s.y-s.height+f+d),("top"===c&&!o||"bottom"===c&&o||"middle"===c)&&("right"===l?x=s.x-d+g:"left"===l&&(x=s.x+d-g)),a={x:x,y:o?b-s.height:b,width:s.bottomWidth,height:s.height},n.verticalAlign="bottom",h&&(n.distance=void 0),h&&t.visible&&E.call(i,t,e,n,a,r),h&&(!t.visible&&t.dataLabel&&(t.dataLabel.placed=!1),t.contrastColor&&e.css({color:t.contrastColor}))}drawDataLabels(){var t;((l(t=this.options.dataLabels||{})?t:[t])[0].inside?m:P).prototype.drawDataLabels.call(this)}getDataLabelPosition(t,e){let n=t.plotY||0,a=t.half?1:-1,r=this.getX(n,!!t.half,t);return{distance:e,natural:{x:0,y:n},computed:{},alignment:t.half?"right":"left",connectorPosition:{breakAt:{x:r+(e-5)*a,y:n},touchingSliceAt:{x:r+e*a,y:n}}}}translate(){let t=this,e=t.chart,n=t.options,i=n.reversed,s=n.ignoreHiddenPoint,l=g(n.borderRadius),d=e.plotWidth,c=e.plotHeight,h=n.center,u=M(h[0],d),f=M(h[1],c),y=M(n.width,d),b=M(n.height,c),x=M(n.neckWidth,d),v=M(n.neckHeight,c),m=f-b/2+b-v,P=t.points,E=p(l.radius,y),O=l.scope,A=+("left"===n.dataLabels.position),W=t=>{let e=Math.tan(t/2),n=Math.cos(I),a=Math.sin(I),r=E,o=r/e,s=Math.tan((Math.PI-t)/3.2104);return o>S&&(r=(o=S)*e),{dx:[o*n,(o-(s*=r))*n,o-s,o],dy:[o*a,(o-s)*a,o-s,o].map(t=>i?-t:t)}},C=0,j=0,k,w,D,I,S,T,_,H,Y,B,F,X;for(let e of(t.getWidthAt=function(t){let e=f-b/2;return t>m||b===v?x:x+(y-x)*(1-(t-e)/(b-v))},t.getX=function(e,n,a){return u+(n?-1:1)*(t.getWidthAt(i?2*f-e:e)/2+(a.dataLabel?.dataLabelPosition?.distance??p(this.options.dataLabels?.distance||0,y)))},t.center=[u,f,b],t.centerX=u,P))e.y&&e.isValid()&&(!s||!1!==e.visible)&&(C+=e.y);for(let e of P){var R;if(X=null,D=C?e.y/C:0,B=(_=f-b/2+j*b)+D*b,H=(T=u-(k=t.getWidthAt(_))/2)+k,F=(Y=u-(k=t.getWidthAt(B))/2)+k,((R=_)>1e14?R:parseFloat(R.toPrecision(14)))>=m?(T=Y=u-x/2,H=F=u+x/2):B>m&&(X=B,F=(Y=u-(k=t.getWidthAt(m))/2)+k,B=m),i&&(_=2*f-_,B=2*f-B,null!==X&&(X=2*f-X)),E&&("point"===O||0===e.index||e.index===P.length-1||null!==X)){let t=Math.abs(B-_),n=H-F,a=F-Y,r=Math.sqrt(n*n+t*t);I=Math.atan(0!==n?t/n:1/0),S=r/2,null!==X&&(S=Math.min(S,Math.abs(X-B)/2)),a>=1&&(S=Math.min(S,a/2));let i=W(I);if(w="stack"===O&&0!==e.index?[["M",T,_],["L",H,_]]:[["M",T+i.dx[0],_+i.dy[0]],["C",T+i.dx[1],_+i.dy[1],T+i.dx[2],_,T+i.dx[3],_],["L",H-i.dx[3],_],["C",H-i.dx[2],_,H-i.dx[1],_+i.dy[1],H-i.dx[0],_+i.dy[0]]],null!==X){let t=W(Math.PI/2);i=W(Math.PI/2+I),w.push(["L",F+i.dx[0],B-i.dy[0]],["C",F+i.dx[1],B-i.dy[1],F,B+i.dy[2],F,B+i.dy[3]]),"stack"===O&&e.index!==P.length-1?w.push(["L",F,X],["L",Y,X]):w.push(["L",F,X-t.dy[3]],["C",F,X-t.dy[2],F-t.dx[2],X,F-t.dx[3],X],["L",Y+t.dx[3],X],["C",Y+t.dx[2],X,Y,X-t.dy[2],Y,X-t.dy[3]]),w.push(["L",Y,B+i.dy[3]],["C",Y,B+i.dy[2],Y-i.dx[1],B-i.dy[1],Y-i.dx[0],B-i.dy[0]])}else a>=1?(i=W(Math.PI-I),"stack"===O&&0===e.index?w.push(["L",F,B],["L",Y,B]):w.push(["L",F+i.dx[0],B-i.dy[0]],["C",F+i.dx[1],B-i.dy[1],F-i.dx[2],B,F-i.dx[3],B],["L",Y+i.dx[3],B],["C",Y+i.dx[2],B,Y-i.dx[1],B-i.dy[1],Y-i.dx[0],B-i.dy[0]])):(i=W(Math.PI-2*I),w.push(["L",Y+i.dx[0],B-i.dy[0]],["C",Y+i.dx[1],B-i.dy[1],Y-i.dx[1],B-i.dy[1],Y-i.dx[0],B-i.dy[0]]))}else w=[["M",T,_],["L",H,_],["L",F,B]],null!==X&&w.push(["L",F,X],["L",Y,X]),w.push(["L",Y,B]);w.push(["Z"]),e.shapeType="path",e.shapeArgs={d:w},e.percentage=100*D,e.plotX=u,e.plotY=(_+(X||B))/2,e.tooltipPos=[u,e.plotY],e.dlBox={x:Y,y:_,topWidth:H-T,bottomWidth:F-Y,height:Math.abs(function(){let t=arguments,e=t.length;for(let n=0;n<e;n++){let e=t[n];if(null!=e)return e}}(X,B)-_),width:NaN},e.slice=L,e.half=A,e.isValid()&&(!s||!1!==e.visible)&&(j+=D)}!function(t,e,n,i){if(n=n||{},r?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==a())){let a=r.createEvent("Events");a.initEvent(e,!0,!0),n=o(a,n),t.dispatchEvent?t.dispatchEvent(n):t.fireEvent(e,n)}else if(t.hcEvents){n.target||o(n,{preventDefault:function(){n.defaultPrevented=!0},target:t,type:e});let a=[],r=t,i=!1;for(;r.hcEvents;)Object.hasOwnProperty.call(r,"hcEvents")&&r.hcEvents[e]&&(a.length&&(i=!0),a.unshift.apply(a,r.hcEvents[e])),r=Object.getPrototypeOf(r);i&&a.sort((t,e)=>t.order-e.order),a.forEach(e=>{!1===e.fn.call(t,n,t)&&n.preventDefault()})}}(t,"afterTranslate")}sortByAngle(t){t.sort((t,e)=>t.plotY-e.plotY)}}function A(){for(let t of this.series){let e=t.options&&t.options.dataLabels;l(e)&&(e=e[0]),t.is("pie")&&t.placeDataLabels&&e&&!e.inside&&t.placeDataLabels()}}O.defaultOptions=c(P.defaultOptions,{animation:!1,borderRadius:0,center:["50%","50%"],width:"90%",neckWidth:"30%",height:"100%",neckHeight:"25%",reversed:!1,size:!0,dataLabels:{connectorWidth:1,verticalAlign:"middle"},states:{select:{color:"#cccccc",borderColor:"#000000"}}}),o(O.prototype,{animate:L}),(O||(O={})).compose=function(t){0>v.indexOf("FunnelSeries")&&v.push("FunnelSeries")&&function(t,e,n,r={}){let i="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(i,"hcEvents")||(i.hcEvents={});let o=i.hcEvents;a().Point&&t instanceof a().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let s=t.addEventListener;s&&s.call(t,e,n,!!a().supportsPassiveEvents&&{passive:void 0===r.passive?-1!==e.indexOf("touch"):r.passive,capture:!1}),o[e]||(o[e]=[]);let l={fn:n,order:"number"==typeof r.order?r.order:1/0};o[e].push(l),o[e].sort((t,e)=>t.order-e.order)}(t,"afterHideAllOverlappingLabels",A)},x().registerSeriesType("funnel",O);let W=O;class C extends W{}C.defaultOptions=c(W.defaultOptions,{neckHeight:"0%",neckWidth:"0%",reversed:!0}),x().registerSeriesType("pyramid",C);let j=a();W.compose(j.Chart);let k=a();export{k as default};