UNPKG

highcharts

Version:
13 lines 4.79 kB
/** * Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/variable-pie * @requires highcharts * * Variable Pie module for Highcharts * * (c) 2010-2026 Highsoft AS * Author: Grzegorz Blachliński * * 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 i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let n=t.default;var i=e.n(n);let r=t.default.SeriesRegistry;var a=e.n(r);let{doc:o,win:l}=i();function s(t,e){let n;for(n in t||(t={}),e)t[n]=e[n];return t}function h(t){return c(t)&&"number"==typeof t.nodeType}function c(t,e){let n;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(n=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==n)}function p(){let t=arguments,e=t.length;for(let n=0;n<e;n++){let e=t[n];if(null!=e)return e}}Array.prototype.find;let{pie:f}=a().seriesTypes;class u extends f{calculateExtremes(){var t,e,n;let i,r,a=this.chart,o=a.plotWidth,l=a.plotHeight,s=this.options,h=2*(s.slicedOffset||0),c=this.getColumn("z"),f=Math.min(o,l)-h,u={},d=this.center||this.getCenter();for(let t of["minPointSize","maxPointSize"]){let e=s[t],n=/%$/.test(e);e=parseInt(e,10),u[t]=n?f*e/100:2*e}this.minPxSize=d[3]+u.minPointSize,this.maxPxSize=(t=d[2],e=d[3]+u.minPointSize,n=u.maxPointSize,t>e?t<n?t:n:e),c.length&&(i=p(s.zMin,function(t){let e=t.length,n=t[0];for(;e--;)t[e]<n&&(n=t[e]);return n}(c.filter(this.zValEval))),r=p(s.zMax,function(t){let e=t.length,n=t[0];for(;e--;)t[e]>n&&(n=t[e]);return n}(c.filter(this.zValEval))),this.getRadii(i,r,this.minPxSize,this.maxPxSize))}getRadii(t,e,n,i){let r,a,o,l=this.getColumn("z"),s=[],h="radius"!==this.options.sizeBy,c=e-t;for(let p=0;p<l.length;p++)(a=this.zValEval(l[p])?l[p]:t)<=t?o=n/2:a>=e?o=i/2:(r=c>0?(a-t)/c:.5,h&&(r=Math.sqrt(r)),o=Math.ceil(n+r*(i-n))/2),s.push(o);this.radii=s}redraw(){this.center=null,super.redraw()}getDataLabelPosition(t,e){let{center:n,options:i}=this,r=t.angle||0,a=this.radii[t.index],o=n[0]+Math.cos(r)*a,l=n[1]+Math.sin(r)*a,s=Math.min((i.slicedOffset||0)+(i.borderWidth||0),e/5);return{distance:e,natural:{x:o+Math.cos(r)*e,y:l+Math.sin(r)*e},computed:{},alignment:t.half?"right":"left",connectorPosition:{breakAt:{x:o+Math.cos(r)*s,y:l+Math.sin(r)*s},touchingSliceAt:{x:o,y:l}}}}translate(t){this.generatePoints();let e=this.options,n=e.slicedOffset,r=e.startAngle||0,a=Math.PI/180*(r-90),l=Math.PI/180*(p(e.endAngle,r+360)-90),h=l-a,c=this.points,f=e.ignoreHiddenPoint,u=0,d,g,y,v,M,P,m;this.startAngleRad=a,this.endAngleRad=l,this.calculateExtremes(),t||(this.center=t=this.getCenter());for(let e=0;e<c.length;e++)P=c[e],m=this.radii[e],d=a+u*h,(!f||P.visible)&&(u+=P.percentage/100),g=a+u*h,P.shapeType="arc",P.shapeArgs={x:t[0],y:t[1],r:m,innerR:t[3]/2,start:Math.round(1e3*d)/1e3,end:Math.round(1e3*g)/1e3},(y=(g+d)/2)>1.5*Math.PI?y-=2*Math.PI:y<-Math.PI/2&&(y+=2*Math.PI),P.slicedTranslation={translateX:Math.round(Math.cos(y)*n),translateY:Math.round(Math.sin(y)*n)},v=Math.cos(y)*t[2]/2,M=Math.sin(y)*t[2]/2,P.tooltipPos=[t[0]+.7*v,t[1]+.7*M],P.half=+(y<-Math.PI/2||y>Math.PI/2),P.angle=y;!function(t,e,n,r){if(n=n||{},o?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==i())){let i=o.createEvent("Events");i.initEvent(e,!0,!0),n=s(i,n),t.dispatchEvent?t.dispatchEvent(n):t.fireEvent(e,n)}else if(t.hcEvents){n.target||s(n,{preventDefault:function(){n.defaultPrevented=!0},target:t,type:e});let i=[],r=t,a=!1;for(;r.hcEvents;)Object.hasOwnProperty.call(r,"hcEvents")&&r.hcEvents[e]&&(i.length&&(a=!0),i.unshift.apply(i,r.hcEvents[e])),r=Object.getPrototypeOf(r);a&&i.sort((t,e)=>t.order-e.order),i.forEach(e=>{!1===e.fn.call(t,n,t)&&n.preventDefault()})}}(this,"afterTranslate")}zValEval(t){return!("number"!=typeof t||isNaN(t))||null}}u.defaultOptions=function(t,...e){let n,i=[t,...e],r={},a=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,n){for(let n in t)Object.hasOwnProperty.call(t,n)&&e.call((0,t[n]),t[n],n,t)}(e,function(n,i){if("__proto__"!==i&&"constructor"!==i){let r;!c(n,!0)||(r=n?.constructor,c(n,!0)&&!h(n)&&r?.name&&"Object"!==r.name)||h(n)?t[i]=e[i]:t[i]=a(t[i]||{},n)}}),t};!0===t&&(r=i[1],i=Array.prototype.slice.call(i,2));let o=i.length;for(n=0;n<o;n++)r=a(r,i[n]);return r}(f.defaultOptions,{minPointSize:"10%",maxPointSize:"100%",zMin:void 0,zMax:void 0,sizeBy:"area",tooltip:{pointFormat:'<span style="color:{point.color}">●</span> {series.name}<br/>Value: {point.y}<br/>Size: {point.z}<br/>'}}),s(u.prototype,{pointArrayMap:["y","z"],parallelArrays:["x","y","z"]}),a().registerSeriesType("variablepie",u);let d=i();export{d as default};