UNPKG

highcharts

Version:
13 lines 5.34 kB
/** * Highcharts JS v13.0.1 (2026-08-17) * @module highcharts/modules/item-series * @requires highcharts * * Item series type for Highcharts * * (c) 2019-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";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 o=0;o<i.length;){var s=i[o++],r=i[o++];e.o(t,s)?0===r&&o++:0===r?Object.defineProperty(t,s,{enumerable:!0,value:i[o++]}):Object.defineProperty(t,s,{enumerable:!0,get:r})}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 o=e.n(i);let s=t.default.SeriesRegistry;var r=e.n(s);let{series:{prototype:{pointClass:a}},seriesTypes:{pie:{prototype:{pointClass:l}}}}=r();class n extends l{}(0,i.extend)(n.prototype,{haloPath:a.prototype.haloPath});let h={endAngle:void 0,innerSize:"40%",itemPadding:.1,layout:"vertical",marker:(0,i.merge)({lineWidth:2,allowPointSelect:!1,crisp:!0,showCheckbox:!1,animation:{duration:1e3},enableMouseTracking:!0,events:{},marker:{enabledThreshold:2,lineColor:"var(--highcharts-background-color)",lineWidth:0,radius:4,states:{normal:{animation:!0},hover:{animation:{duration:150},enabled:!0,radiusPlus:2,lineWidthPlus:1},select:{fillColor:"var(--highcharts-neutral-color-20)",lineColor:"var(--highcharts-neutral-color-100)",lineWidth:2}}},point:{events:{}},dataLabels:{animation:{},align:"center",borderWidth:0,defer:!0,distance:4,formatter:function(){let{numberFormatter:t}=this.series.chart;return"number"!=typeof this.y?"":t(this.y,-1)},padding:[1,3],style:{fontSize:"0.7em",fontWeight:"bold",color:"contrast",textOutline:"1px contrast"},verticalAlign:"bottom",x:0,y:0},cropThreshold:300,opacity:1,pointRange:0,softThreshold:!0,states:{normal:{animation:!0},hover:{animation:{duration:150},lineWidthPlus:1,marker:{},halo:{size:10,opacity:.25}},select:{animation:{duration:0}},inactive:{animation:{duration:150},opacity:.2}},stickyTracking:!0,turboThreshold:1e3,findNearestPointBy:"x"}.marker,{radius:null}),rows:void 0,crisp:!1,showInLegend:!0,startAngle:void 0},{pie:d}=r().seriesTypes;class c extends d{animate(t){let e=this.group;e&&(t?e.attr({opacity:0}):e.animate({opacity:1},this.options.animation))}drawDataLabels(){if(this.center&&this.slots)super.drawDataLabels();else for(let t of this.points)t.destroyElements({dataLabel:1})}drawPoints(){let t=this.options,e=this.chart.renderer,o=t.marker,s=this.borderWidth%2?.5:1,r=this.getRows(),a=Math.ceil(this.total/r),l=this.chart.plotWidth/a,n=this.chart.plotHeight/r,h=this.itemSize||Math.min(l,n),d=0;for(let c of this.points){let p,u,g,f,m,y,b=c.marker||{},v=b.symbol||o.symbol,M=(0,i.pick)(b.radius,o.radius),w=(0,i.defined)(M)?2*M:h,A=w*t.itemPadding;if(c.graphics=u=c.graphics||[],this.chart.styledMode||(g=this.pointAttribs(c,c.selected&&"select")),!c.isNull&&c.visible){c.graphic||(c.graphic=e.g("point").add(this.group));for(let o=0;o<(c.y||0);++o){if(this.center&&this.slots){let t=this.slots.shift();f=t.x-h/2,m=t.y-h/2}else"horizontal"===t.layout?(f=d%a*l,m=n*Math.floor(d/a)):(f=l*Math.floor(d/r),m=d%r*n);f+=A,m+=A,y=Math.round(w-2*A),this.options.crisp&&(f=Math.round(f)-s,m=Math.round(m)+s),p={x:f,y:m,width:y,height:y},void 0!==M&&(p.r=M),g&&(0,i.extend)(p,g);let b=u[o];b?b.animate(p):b=e.symbol(v,void 0,void 0,void 0,void 0,{backgroundSize:"within"}).attr(p).add(c.graphic),b.isActive=!0,u[o]=b,++d}}for(let t=0;t<u.length;t++){let e=u[t];if(!e)return;e.isActive?e.isActive=!1:(e.destroy(),u.splice(t,1),t--)}}}getRows(){let t=this.chart,e=this.total||0,i=this.options.rows,o;if(!i)if(o=t.plotWidth/t.plotHeight,i=Math.sqrt(e),o>1)for(i=Math.ceil(i);i>1&&!(e/i/i>o);)i--;else for(i=Math.floor(i);i<e&&!(e/i/i<o);)i++;return i}getSlots(){let t=this.center,e=t[2],i=this.slots=this.slots||[],o=this.endAngleRad-this.startAngleRad,s=this.options.rows,r=o%(2*Math.PI)==0,a=this.total||0,l=t[3],n,h,d,c,p,u,g,f,m=0,y,b=Number.MAX_VALUE,v,M,w,A=(e-l)/e;for(;b>a+(M&&r?M.length:0);){v=b,i.length=0,b=0,M=w,w=[],y=e/++m/2,s?(l=(y-s)/y*e)>=0?y=s:(l=0,A=1):y=Math.floor(y*A);for(let t=y;t>0;t--)p=Math.ceil((c=o*(d=(l+t/y*(e-l-m))/2))/m),w.push({rowRadius:d,rowLength:c,colCount:p}),b+=p+1}if(!M)return;let P=v-this.total-(r?M.length:0),k=t=>{P>0&&(t.row.colCount--,P--)};for(;P>0;)M.map(t=>({angle:t.colCount/t.rowLength,row:t})).sort((t,e)=>e.angle-t.angle).slice(0,Math.min(P,Math.ceil(M.length/2))).forEach(k);for(let e of M){let s=e.rowRadius,r=e.colCount;for(f=0,u=r?o/r:0;f<=r;f+=1)g=this.startAngleRad+f*u,n=t[0]+Math.cos(g)*s,h=t[1]+Math.sin(g)*s,i.push({x:n,y:h,angle:g})}return i.sort((t,e)=>t.angle-e.angle),this.itemSize=m,i}translate(t){0===this.total&&(0,i.isNumber)(this.options.startAngle)&&(0,i.isNumber)(this.options.endAngle)&&(this.center=this.getCenter()),this.slots||(this.slots=[]),(0,i.isNumber)(this.options.startAngle)&&(0,i.isNumber)(this.options.endAngle)?(super.translate(t),this.slots=this.getSlots()):(this.generatePoints(),(0,i.fireEvent)(this,"afterTranslate"))}}c.defaultOptions=(0,i.merge)(d.defaultOptions,h),(0,i.extend)(c.prototype,{markerAttribs:void 0,pointClass:n}),r().registerSeriesType("item",c);let p=o();export{p as default};