highcharts
Version:
JavaScript charting framework
11 lines • 6.38 kB
JavaScript
!/**
* Highcharts JS v12.1.2 (2024-12-21)
* @module highcharts/modules/funnel
* @requires highcharts
*
* Highcharts funnel module
*
* (c) 2010-2024 Torstein Honsi
*
* License: www.highcharts.com/license
*/function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts,t._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/modules/funnel",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/funnel"]=e(t._Highcharts,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.SeriesRegistry)}("undefined"==typeof window?this:window,(t,e)=>(()=>{"use strict";var i={512:t=>{t.exports=e},944:e=>{e.exports=t}},a={};function d(t){var e=a[t];if(void 0!==e)return e.exports;var s=a[t]={exports:{}};return i[t](s,s.exports,d),s.exports}d.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return d.d(e,{a:e}),e},d.d=(t,e)=>{for(var i in e)d.o(e,i)&&!d.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},d.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var s={};d.d(s,{default:()=>X});var o=d(944),n=d.n(o);let{defaultOptions:r}=n(),{noop:l}=n(),{addEvent:h,extend:p,isObject:c,merge:u,relativeLength:g}=n(),x={radius:0,scope:"stack",where:void 0},y={optionsToObject:function(t,e){return c(t)||(t={radius:t||0}),u(x,e,t)}};var f=d(512),b=d.n(f);let{composed:L,noop:m}=n(),{column:v,pie:M}=b().seriesTypes,{addEvent:W,correctFloat:A,extend:C,fireEvent:H,isArray:w,merge:P,pick:k,pushUnique:O,relativeLength:S,splat:j}=n(),D=b().series.prototype.alignDataLabel;function I(t,e){return/%$/.test(t)?e*parseInt(t,10)/100:parseInt(t,10)}class T extends M{alignDataLabel(t,e,i,a,d){let s=t.series,o=s.options.reversed,n=t.dlBox||t.shapeArgs,{align:r,padding:l=0,verticalAlign:h}=i,p=((s.options||{}).dataLabels||{}).inside,c=s.center[1],u=t.plotY||0,g=e.height??e.getBBox().height,x=s.getWidthAt((o?2*c-u:u)-n.height/2+g),y="middle"===h?(n.topWidth-n.bottomWidth)/4:(x-n.bottomWidth)/2,f=n.y,b=n.x;"middle"===h?f=n.y-n.height/2+g/2:"top"===h&&(f=n.y-n.height+g+l),("top"===h&&!o||"bottom"===h&&o||"middle"===h)&&("right"===r?b=n.x-l+y:"left"===r&&(b=n.x+l-y)),a={x:b,y:o?f-n.height:f,width:n.bottomWidth,height:n.height},i.verticalAlign="bottom",p&&(i.distance=void 0),p&&t.visible&&D.call(s,t,e,i,a,d),p&&(!t.visible&&t.dataLabel&&(t.dataLabel.placed=!1),t.contrastColor&&e.css({color:t.contrastColor}))}drawDataLabels(){(j(this.options.dataLabels||{})[0].inside?v:M).prototype.drawDataLabels.call(this)}getDataLabelPosition(t,e){let i=t.plotY||0,a=t.half?1:-1,d=this.getX(i,!!t.half,t);return{distance:e,natural:{x:0,y:i},computed:{},alignment:t.half?"right":"left",connectorPosition:{breakAt:{x:d+(e-5)*a,y:i},touchingSliceAt:{x:d+e*a,y:i}}}}translate(){let t=this,e=t.chart,i=t.options,a=i.reversed,d=i.ignoreHiddenPoint,s=y.optionsToObject(i.borderRadius),o=e.plotWidth,n=e.plotHeight,r=i.center,l=I(r[0],o),h=I(r[1],n),p=I(i.width,o),c=I(i.height,n),u=I(i.neckWidth,o),g=I(i.neckHeight,n),x=h-c/2+c-g,f=t.points,b=S(s.radius,p),L=s.scope,v="left"===i.dataLabels.position?1:0,M=t=>{let e=Math.tan(t/2),i=Math.cos(j),d=Math.sin(j),s=b,o=s/e,n=Math.tan((Math.PI-t)/3.2104);return o>D&&(s=(o=D)*e),{dx:[o*i,(o-(n*=s))*i,o-n,o],dy:[o*d,(o-n)*d,o-n,o].map(t=>a?-t:t)}},W=0,C=0,w,P,O,j,D,T,R,Y,_,B,X,N;for(let e of(t.getWidthAt=function(t){let e=h-c/2;return t>x||c===g?u:u+(p-u)*(1-(t-e)/(c-g))},t.getX=function(e,i,d){return l+(i?-1:1)*(t.getWidthAt(a?2*h-e:e)/2+(d.dataLabel?.dataLabelPosition?.distance??S(this.options.dataLabels?.distance||0,p)))},t.center=[l,h,c],t.centerX=l,f))e.y&&e.isValid()&&(!d||!1!==e.visible)&&(W+=e.y);for(let e of f){if(N=null,O=W?e.y/W:0,B=(R=h-c/2+C*c)+O*c,Y=(T=l-(w=t.getWidthAt(R))/2)+w,X=(_=l-(w=t.getWidthAt(B))/2)+w,A(R)>=x?(T=_=l-u/2,Y=X=l+u/2):B>x&&(N=B,X=(_=l-(w=t.getWidthAt(x))/2)+w,B=x),a&&(R=2*h-R,B=2*h-B,null!==N&&(N=2*h-N)),b&&("point"===L||0===e.index||e.index===f.length-1||null!==N)){let t=Math.abs(B-R),i=Y-X,a=X-_,d=Math.sqrt(i*i+t*t);j=Math.atan(0!==i?t/i:1/0),D=d/2,null!==N&&(D=Math.min(D,Math.abs(N-B)/2)),a>=1&&(D=Math.min(D,a/2));let s=M(j);if(P="stack"===L&&0!==e.index?[["M",T,R],["L",Y,R]]:[["M",T+s.dx[0],R+s.dy[0]],["C",T+s.dx[1],R+s.dy[1],T+s.dx[2],R,T+s.dx[3],R],["L",Y-s.dx[3],R],["C",Y-s.dx[2],R,Y-s.dx[1],R+s.dy[1],Y-s.dx[0],R+s.dy[0]]],null!==N){let t=M(Math.PI/2);s=M(Math.PI/2+j),P.push(["L",X+s.dx[0],B-s.dy[0]],["C",X+s.dx[1],B-s.dy[1],X,B+s.dy[2],X,B+s.dy[3]]),"stack"===L&&e.index!==f.length-1?P.push(["L",X,N],["L",_,N]):P.push(["L",X,N-t.dy[3]],["C",X,N-t.dy[2],X-t.dx[2],N,X-t.dx[3],N],["L",_+t.dx[3],N],["C",_+t.dx[2],N,_,N-t.dy[2],_,N-t.dy[3]]),P.push(["L",_,B+s.dy[3]],["C",_,B+s.dy[2],_-s.dx[1],B-s.dy[1],_-s.dx[0],B-s.dy[0]])}else a>=1?(s=M(Math.PI-j),"stack"===L&&0===e.index?P.push(["L",X,B],["L",_,B]):P.push(["L",X+s.dx[0],B-s.dy[0]],["C",X+s.dx[1],B-s.dy[1],X-s.dx[2],B,X-s.dx[3],B],["L",_+s.dx[3],B],["C",_+s.dx[2],B,_-s.dx[1],B-s.dy[1],_-s.dx[0],B-s.dy[0]])):(s=M(Math.PI-2*j),P.push(["L",_+s.dx[0],B-s.dy[0]],["C",_+s.dx[1],B-s.dy[1],_-s.dx[1],B-s.dy[1],_-s.dx[0],B-s.dy[0]]))}else P=[["M",T,R],["L",Y,R],["L",X,B]],null!==N&&P.push(["L",X,N],["L",_,N]),P.push(["L",_,B]);P.push(["Z"]),e.shapeType="path",e.shapeArgs={d:P},e.percentage=100*O,e.plotX=l,e.plotY=(R+(N||B))/2,e.tooltipPos=[l,e.plotY],e.dlBox={x:_,y:R,topWidth:Y-T,bottomWidth:X-_,height:Math.abs(k(N,B)-R),width:NaN},e.slice=m,e.half=v,e.isValid()&&(!d||!1!==e.visible)&&(C+=O)}H(t,"afterTranslate")}sortByAngle(t){t.sort((t,e)=>t.plotY-e.plotY)}}T.defaultOptions=P(M.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"}}}),C(T.prototype,{animate:m}),function(t){function e(){for(let t of this.series){let e=t.options&&t.options.dataLabels;w(e)&&(e=e[0]),t.is("pie")&&t.placeDataLabels&&e&&!e.inside&&t.placeDataLabels()}}t.compose=function(t){O(L,"FunnelSeries")&&W(t,"afterHideAllOverlappingLabels",e)}}(T||(T={})),b().registerSeriesType("funnel",T);let R=T,{merge:Y}=n();class _ extends R{}_.defaultOptions=Y(R.defaultOptions,{neckHeight:"0%",neckWidth:"0%",reversed:!0}),b().registerSeriesType("pyramid",_);let B=n();R.compose(B.Chart);let X=n();return s.default})());