UNPKG

highcharts

Version:
11 lines 11.5 kB
!/** * Highcharts JS v12.6.0 (2026-04-13) * @module highcharts/modules/wordcloud * @requires highcharts * * (c) 2016-2026 Highsoft AS * Authors: Jon Arild Nygård * * A commercial license may be required depending on use. * See 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/wordcloud",["highcharts/highcharts"],function(t){return e(t,t.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/modules/wordcloud"]=e(t._Highcharts,t._Highcharts.SeriesRegistry):t.Highcharts=e(t.Highcharts,t.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(t,e)=>(()=>{"use strict";var i={512:t=>{t.exports=e},944:e=>{e.exports=t}},o={};function n(t){var e=o[t];if(void 0!==e)return e.exports;var r=o[t]={exports:{}};return i[t](r,r.exports,n),r.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var r={};n.d(r,{default:()=>J});var a=n(944),l=n.n(a);let s=function(t,e){let{animatableAttribs:i,onComplete:o,css:n,renderer:r}=e,a=t.series&&t.series.chart.hasRendered?void 0:t.series&&t.series.options.animation,l=t.graphic;if(e.attribs={...e.attribs,class:t.getClassName()},t.shouldDraw())l||(t.graphic=l="text"===e.shapeType?r.text():"image"===e.shapeType?r.image(e.imageUrl||"").attr(e.shapeArgs||{}):r[e.shapeType](e.shapeArgs||{}),l.add(e.group)),n&&l.css(n),l.attr(e.attribs).animate(i,!e.isNew&&a,o);else if(l){let e=()=>{t.graphic=l=l&&l.destroy(),"function"==typeof o&&o()};Object.keys(i).length?l.animate(i,void 0,()=>e()):e()}};var h=n(512),p=n.n(h);let{doc:c,win:u}=l();function d(t,e){let i;for(i in t||(t={}),e)t[i]=e[i];return t}let g=Array.prototype.find?function(t,e){return t.find(e)}:function(t,e){let i,o=t.length;for(i=0;i<o;i++)if(e(t[i],i))return t[i]};function f(t){return x(t)&&"number"==typeof t.nodeType}function m(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function y(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function x(t,e){return!!t&&"object"==typeof t&&(!e||!y(t))}function b(t,...e){let i,o=[t,...e],n={},r=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 n;!x(i,!0)||(n=i?.constructor,x(i,!0)&&!f(i)&&n?.name&&"Object"!==n.name)||f(i)?t[o]=e[o]:t[o]=r(t[o]||{},i)}}),t};!0===t&&(n=o[1],o=Array.prototype.slice.call(o,2));let a=o.length;for(i=0;i<a;i++)n=r(n,o[i]);return n}let{column:{prototype:{pointClass:M}}}=p().seriesTypes;class w extends M{isValid(){return!0}}d(w.prototype,{weight:1});let{deg2rad:S}=l();function A(t,e){return!(e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top)}function P(t){let e,i=t.axes||[];return i.length||(i=[],(e=t.concat([t[0]])).reduce((t,e)=>{let o,n,r=(o=e[0]-t[0],[[-(n=e[1]-t[1]),o],[n,-o]])[0];return g(i,t=>t[0]===r[0]&&t[1]===r[1])||i.push(r),e}),t.axes=i),i}function F(t,e){let i=t.map(t=>{let i=t[0],o=t[1];return i*e[0]+o*e[1]});return{min:Math.min.apply(this,i),max:Math.max.apply(this,i)}}function X(t,e){let i=P(t),o=P(e);return!g(i.concat(o),i=>{let o,n;return o=F(t,i),!!((n=F(e,i)).min>o.max||n.max<o.min)})}function v(t,e){let i=4*t,o=Math.ceil((Math.sqrt(i)-1)/2),n=2*o+1,r=Math.pow(n,2),a=!1;return n-=1,t<=1e4&&("boolean"==typeof a&&i>=r-n&&(a={x:o-(r-i),y:-o}),r-=n,"boolean"==typeof a&&i>=r-n&&(a={x:-o,y:-o+(r-i)}),r-=n,"boolean"==typeof a&&(a=i>=r-n?{x:-o+(r-i),y:o}:{x:o,y:o-(r-i-n)}),a.x*=5,a.y*=5),a}function T(t,e){let i=Math.pow(10,m(e)?e:14);return Math.round(t*i)/i}function z(t,e){let i=t[0],o=t[1],n=-(S*e),r=Math.cos(n),a=Math.sin(n);return[T(i*r-o*a),T(i*a+o*r)]}function _(t,e,i){let o=z([t[0]-e[0],t[1]-e[1]],i);return[o[0]+e[0],o[1]+e[1]]}let{noop:j}=l(),{column:Y}=p().seriesTypes,{archimedeanSpiral:H,extendPlayingField:O,getBoundingBoxFromPolygon:R,getPlayingField:B,getPolygon:C,getRandomPosition:N,getRotation:W,getScale:D,getSpiral:E,intersectionTesting:L,isPolygonsColliding:U,rectangularSpiral:V,rotate2DToOrigin:q,rotate2DToPoint:k,squareSpiral:I,updateFieldBoundaries:K}={archimedeanSpiral:function(t,e){let i=e.field,o=i.width*i.width+i.height*i.height,n=.8*t,r=!1;return t<=1e4&&(Math.min(Math.abs((r={x:n*Math.cos(n),y:n*Math.sin(n)}).x),Math.abs(r.y))<o||(r=!1)),r},extendPlayingField:function(t,e){let i,o,n,r,a,l;return x(t)&&x(e)?(i=e.bottom-e.top,o=e.right-e.left,a=o*(n=t.ratioX)>i*(r=t.ratioY)?o:i,l=b(t,{width:t.width+a*n*2,height:t.height+a*r*2})):l=t,l},getBoundingBoxFromPolygon:function(t){return t.reduce(function(t,e){let i=e[0],o=e[1];return t.left=Math.min(i,t.left),t.right=Math.max(i,t.right),t.bottom=Math.max(o,t.bottom),t.top=Math.min(o,t.top),t},{left:Number.MAX_VALUE,right:-Number.MAX_VALUE,bottom:-Number.MAX_VALUE,top:Number.MAX_VALUE})},getPlayingField:function(t,e,i){let o=i.reduce(function(t,e){let i=e.dimensions,o=Math.max(i.width,i.height);return t.maxHeight=Math.max(t.maxHeight,i.height),t.maxWidth=Math.max(t.maxWidth,i.width),t.area+=o*o,t},{maxHeight:0,maxWidth:0,area:0}),n=Math.max(o.maxHeight,o.maxWidth,.85*Math.sqrt(o.area)),r=t>e?t/e:1,a=e>t?e/t:1;return{width:n*r,height:n*a,ratioX:r,ratioY:a}},getPolygon:function(t,e,i,o,n){let r=[t,e],a=t-i/2,l=t+i/2,s=e-o/2,h=e+o/2;return[[a,s],[l,s],[l,h],[a,h]].map(function(t){return _(t,r,-n)})},getRandomPosition:function(t){return Math.round(t*(Math.random()+.5)/2)},getRotation:function(t,e,i,o){let n=!1,r;return m(t)&&m(e)&&m(i)&&m(o)&&t>0&&e>-1&&o>i&&(r=(o-i)/(t-1||1),n=i+e%t*r),n},getScale:function(t,e,i){let o=2*Math.max(Math.abs(i.top),Math.abs(i.bottom)),n=2*Math.max(Math.abs(i.left),Math.abs(i.right));return Math.min(n>0?1/n*t:1,o>0?1/o*e:1)},getSpiral:function(t,e){let i=[];for(let o=1;o<1e4;o++)i.push(t(o,e));return t=>t<=1e4&&i[t-1]},intersectionTesting:function(t,e){let i,o,n,r,a,l,s=e.placed,h=e.field,p=e.rectangle,c=e.polygon,u=e.spiral,f=t.rect=d({},p),m=1,y={x:0,y:0};for(t.polygon=c,t.rotation=e.rotation;!1!==y&&(i=t.rect,o=t.polygon,n=t.lastCollidedWith,r=function(e){let n=A(i,e.rect);return n&&(t.rotation%90||e.rotation%90)&&(n=X(o,e.polygon)),n},a=!1,n&&!(a=r(n))&&delete t.lastCollidedWith,!a&&(a=!!g(s,function(e){let i=r(e);return i&&(t.lastCollidedWith=e),i})),a||!((l={left:-(h.width/2),right:h.width/2,top:-(h.height/2),bottom:h.height/2}).left<f.left&&l.right>f.right&&l.top<f.top&&l.bottom>f.bottom));)x(y=u(m))&&(f.left=p.left+y.x,f.right=p.right+y.x,f.top=p.top+y.y,f.bottom=p.bottom+y.y,t.polygon=function(t,e,i){return i.map(function(i){return[i[0]+t,i[1]+e]})}(y.x,y.y,c)),m++;return y},isPolygonsColliding:X,isRectanglesIntersecting:A,rectangularSpiral:function(t,e){let i=v(t,e),o=e.field;return i&&(i.x*=o.ratioX,i.y*=o.ratioY),i},rotate2DToOrigin:z,rotate2DToPoint:_,squareSpiral:v,updateFieldBoundaries:function(t,e){return(!m(t.left)||t.left>e.left)&&(t.left=e.left),(!m(t.right)||t.right<e.right)&&(t.right=e.right),(!m(t.top)||t.top>e.top)&&(t.top=e.top),(!m(t.bottom)||t.bottom<e.bottom)&&(t.bottom=e.bottom),t}};class G extends Y{pointAttribs(t,e){let i=l().seriesTypes.column.prototype.pointAttribs.call(this,t,e);return delete i.stroke,delete i["stroke-width"],i}deriveFontSize(t,e,i){let o=m(t)?t:0,n=m(e)?e:1;return Math.floor(Math.max(m(i)?i:1,o*n))}drawPoints(){if(this.zooming||this.defaultScale&&this.group.scaleX!==this.defaultScale)return;let t=this.hasRendered,e=this.xAxis,i=this.yAxis,o=this.chart,n=this.group,r=this.options,a=r.animation,l=r.allowExtendPlayingField,h=o.renderer,p=[],c=this.placementStrategy[r.placementStrategy],u=r.rotation,g=this.points.map(function(t){return t.weight}),f=Math.max.apply(null,g),y=this.points.concat().sort((t,e)=>e.weight-t.weight),b=h.text().add(n),M;for(let t of(this.group.attr({scaleX:1,scaleY:1}),y)){let e=1/f*t.weight,i=d({fontSize:this.deriveFontSize(e,r.maxFontSize,r.minFontSize)+"px"},r.style);b.css(i).attr({x:0,y:0,text:t.name});let o=b.getBBox(!0);t.dimensions={height:o.height,width:o.width}}M=B(e.len,i.len,y);let w=E(this.spirals[r.spiral],{field:M});for(let e of y){let i=1/f*e.weight,o=d({fontSize:this.deriveFontSize(i,r.maxFontSize,r.minFontSize)+"px"},r.style),g=c(e,{data:y,field:M,placed:p,rotation:u}),b=d(this.pointAttribs(e,e.selected&&"select"),{align:"center","alignment-baseline":"middle","dominant-baseline":"middle",x:g.x,y:g.y,text:e.name,rotation:m(g.rotation)?g.rotation:void 0}),S=C(g.x,g.y,e.dimensions.width,e.dimensions.height,g.rotation),A=R(S),P=L(e,{rectangle:A,polygon:S,field:M,placed:p,spiral:w,rotation:g.rotation}),F;!P&&l&&(M=O(M,A),P=L(e,{rectangle:A,polygon:S,field:M,placed:p,spiral:w,rotation:g.rotation})),x(P)?(b.x=(b.x||0)+P.x,b.y=(b.y||0)+P.y,A.left+=P.x,A.right+=P.x,A.top+=P.y,A.bottom+=P.y,M=K(M,A),p.push(e),e.isNull=!1,e.isInside=!0):e.isNull=!0,a&&(F={x:b.x,y:b.y},t?(delete b.x,delete b.y):(b.x=0,b.y=0)),s(e,{animatableAttribs:F,attribs:b,css:o,group:n,renderer:h,shapeArgs:void 0,shapeType:"text"})}b=b.destroy(),this.defaultScale=D(e.len,i.len,M),this.field=M,this.group.attr({scaleX:this.defaultScale,scaleY:this.defaultScale})}hasData(){return x(this)&&!0===this.visible&&y(this.points)&&this.points.length>0}getPlotBox(t){let{chart:e,group:i,zooming:o}=this,{plotSizeX:n=0,plotSizeY:r=0,inverted:a}=e,l=this[a?"yAxis":"xAxis"],s=this[a?"xAxis":"yAxis"],h=l?l.len:e.plotWidth,p=s?s.len:e.plotHeight,c=l?l.left:e.plotLeft,u=s?s.top:e.plotTop,d=this.field,g=0,f=0,y=c+h/2,x=u+p/2,b=y,M=x,w=this.defaultScale||1,S=0,A=0;if(d&&(S=2*Math.max(Math.abs(d.top),Math.abs(d.bottom)),A=2*Math.max(Math.abs(d.left),Math.abs(d.right))),a&&([A,S]=[S,A]),i&&o){let e=c+Math.max(A*(w=Math.max(o.scale,this.defaultScale||1)),h)/2,a=u+Math.max(S*w,p)/2,l=w-(i.scaleX||1);g=l*((n-A)/2+o.zoomX*n-h/2),f=l*((r-S)/2+o.zoomY*r-p/2),"series"===t&&(o.x=Math.max(0,Math.min(1-o.width,o.x+o.panX/o.scale)),g+=o.panX*n,o.panX=0,o.y=Math.max(0,Math.min(1-o.height,o.y+o.panY/o.scale)),f+=o.panY*r,o.panY=0),m(i.translateX)&&m(i.translateY)&&(b=i.translateX,M=i.translateY),y=b-g,(x=M-f)>a?x=a:x<2*u+p-a&&(x=2*u+p-a),y>e?y=e:y<2*c+h-e&&(y=2*c+h-e)}return{translateX:y,translateY:x,scaleX:w,scaleY:w}}}G.defaultOptions=b(Y.defaultOptions,{allowExtendPlayingField:!0,animation:{duration:500},borderWidth:0,clip:!1,colorByPoint:!0,cropThreshold:1/0,colorKey:"weight",minFontSize:1,maxFontSize:25,placementStrategy:"center",rotation:{from:0,orientations:2,to:90},showInLegend:!1,spiral:"rectangular",style:{fontFamily:"sans-serif",fontWeight:"900",whiteSpace:"nowrap"},tooltip:{followPointer:!0,pointFormat:'<span style="color:{point.color}">●</span> {series.name}: <b>{point.weight}</b><br/>'}}),d(G.prototype,{animate:j,animateDrilldown:j,animateDrillupFrom:j,isCartesian:!1,pointClass:w,setClip:j,placementStrategy:{random:function(t,e){let i=e.field,o=e.rotation;return{x:N(i.width)-i.width/2,y:N(i.height)-i.height/2,rotation:W(o.orientations,t.index,o.from,o.to)}},center:function(t,e){let i=e.rotation;return{x:0,y:0,rotation:W(i.orientations,t.index,i.from,i.to)}}},pointArrayMap:["weight"],spirals:{archimedean:H,rectangular:V,square:I},utils:{extendPlayingField:O,getRotation:W,isPolygonsColliding:U,rotate2DToOrigin:q,rotate2DToPoint:k}}),p().registerSeriesType("wordcloud",G);let J=l();return r.default})());