UNPKG

highcharts

Version:
13 lines 6.38 kB
/** * Highcharts JS v12.6.0 (2026-04-13) * @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";var e={};e.n=t=>{var i=t&&t.__esModule?()=>t.default:()=>t;return e.d(i,{a:i}),i},e.d=(t,i)=>{for(var o in i)e.o(i,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:i[o]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=t.default;var o=e.n(i);let r=t.default.SeriesRegistry;var s=e.n(r);let{doc:n,win:a}=o();function l(t,e){let i;for(i in t||(t={}),e)t[i]=e[i];return t}function h(t){return d(t)&&"number"==typeof t.nodeType}function c(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function d(t,e){let i;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(i=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==i)}function p(t,...e){let i,o=[t,...e],r={},s=function(t,e){return"object"!=typeof t&&(t={}),function(t,e,i){for(let i in t)Object.hasOwnProperty.call(t,i)&&e.call((0,t[i]),t[i],i,t)}(e,function(i,o){if("__proto__"!==o&&"constructor"!==o){let r;!d(i,!0)||(r=i?.constructor,d(i,!0)&&!h(i)&&r?.name&&"Object"!==r.name)||h(i)?t[o]=e[o]:t[o]=s(t[o]||{},i)}}),t};!0===t&&(r=o[1],o=Array.prototype.slice.call(o,2));let n=o.length;for(i=0;i<n;i++)r=s(r,o[i]);return r}Array.prototype.find;let{series:{prototype:{pointClass:f}},seriesTypes:{pie:{prototype:{pointClass:u}}}}=s();class g extends u{}l(g.prototype,{haloPath:f.prototype.haloPath});let y={endAngle:void 0,innerSize:"40%",itemPadding:.1,layout:"vertical",marker:p({lineWidth:2,allowPointSelect:!1,crisp:!0,showCheckbox:!1,animation:{duration:1e3},enableMouseTracking:!0,events:{},marker:{enabledThreshold:2,lineColor:"#ffffff",lineWidth:0,radius:4,states:{normal:{animation:!0},hover:{animation:{duration:150},enabled:!0,radiusPlus:2,lineWidthPlus:1},select:{fillColor:"#cccccc",lineColor:"#000000",lineWidth:2}}},point:{events:{}},dataLabels:{animation:{},align:"center",borderWidth:0,defer:!0,formatter:function(){let{numberFormatter:t}=this.series.chart;return"number"!=typeof this.y?"":t(this.y,-1)},padding:5,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:m}=s().seriesTypes;class v extends m{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,i=t.marker,o=this.borderWidth%2?.5:1,r=this.getRows(),s=Math.ceil(this.total/r),n=this.chart.plotWidth/s,a=this.chart.plotHeight/r,h=this.itemSize||Math.min(n,a),c=0;for(let d of this.points){let p,f,u,g,y,m,v=d.marker||{},b=v.symbol||i.symbol,w=function(){let t=arguments,e=t.length;for(let i=0;i<e;i++){let e=t[i];if(null!=e)return e}}(v.radius,i.radius),A=null!=w?2*w:h,M=A*t.itemPadding;if(d.graphics=f=d.graphics||[],this.chart.styledMode||(u=this.pointAttribs(d,d.selected&&"select")),!d.isNull&&d.visible){d.graphic||(d.graphic=e.g("point").add(this.group));for(let i=0;i<(d.y||0);++i){if(this.center&&this.slots){let t=this.slots.shift();g=t.x-h/2,y=t.y-h/2}else"horizontal"===t.layout?(g=c%s*n,y=a*Math.floor(c/s)):(g=n*Math.floor(c/r),y=c%r*a);g+=M,y+=M,m=Math.round(A-2*M),this.options.crisp&&(g=Math.round(g)-o,y=Math.round(y)+o),p={x:g,y:y,width:m,height:m},void 0!==w&&(p.r=w),u&&l(p,u);let v=f[i];v?v.animate(p):v=e.symbol(b,void 0,void 0,void 0,void 0,{backgroundSize:"within"}).attr(p).add(d.graphic),v.isActive=!0,f[i]=v,++c}}for(let t=0;t<f.length;t++){let e=f[t];if(!e)return;e.isActive?e.isActive=!1:(e.destroy(),f.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,r=this.options.rows,s=o%(2*Math.PI)==0,n=this.total||0,a=t[3],l,h,c,d,p,f,u,g,y=0,m,v=Number.MAX_VALUE,b,w,A,M=(e-a)/e;for(;v>n+(w&&s?w.length:0);){b=v,i.length=0,v=0,w=A,A=[],m=e/++y/2,r?(a=(m-r)/m*e)>=0?m=r:(a=0,M=1):m=Math.floor(m*M);for(let t=m;t>0;t--)p=Math.ceil((d=o*(c=(a+t/m*(e-a-y))/2))/y),A.push({rowRadius:c,rowLength:d,colCount:p}),v+=p+1}if(!w)return;let E=b-this.total-(s?w.length:0),P=t=>{E>0&&(t.row.colCount--,E--)};for(;E>0;)w.map(t=>({angle:t.colCount/t.rowLength,row:t})).sort((t,e)=>e.angle-t.angle).slice(0,Math.min(E,Math.ceil(w.length/2))).forEach(P);for(let e of w){let r=e.rowRadius,s=e.colCount;for(g=0,f=s?o/s:0;g<=s;g+=1)u=this.startAngleRad+g*f,l=t[0]+Math.cos(u)*r,h=t[1]+Math.sin(u)*r,i.push({x:l,y:h,angle:u})}return i.sort((t,e)=>t.angle-e.angle),this.itemSize=y,i}translate(t){0===this.total&&c(this.options.startAngle)&&c(this.options.endAngle)&&(this.center=this.getCenter()),this.slots||(this.slots=[]),c(this.options.startAngle)&&c(this.options.endAngle)?(super.translate(t),this.slots=this.getSlots()):(this.generatePoints(),function(t,e,i,r){if(i=i||{},n?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==o())){let o=n.createEvent("Events");o.initEvent(e,!0,!0),i=l(o,i),t.dispatchEvent?t.dispatchEvent(i):t.fireEvent(e,i)}else if(t.hcEvents){i.target||l(i,{preventDefault:function(){i.defaultPrevented=!0},target:t,type:e});let o=[],r=t,s=!1;for(;r.hcEvents;)Object.hasOwnProperty.call(r,"hcEvents")&&r.hcEvents[e]&&(o.length&&(s=!0),o.unshift.apply(o,r.hcEvents[e])),r=Object.getPrototypeOf(r);s&&o.sort((t,e)=>t.order-e.order),o.forEach(e=>{!1===e.fn.call(t,i,t)&&i.preventDefault()})}}(this,"afterTranslate"))}}v.defaultOptions=p(m.defaultOptions,y),l(v.prototype,{markerAttribs:void 0,pointClass:g}),s().registerSeriesType("item",v);let b=o();export{b as default};