highcharts
Version:
JavaScript charting framework
11 lines • 11.1 kB
JavaScript
!/**
* Highcharts JS v13.0.1 (2026-08-17)
* @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}};let o={};function r(t){let e=o[t];if(void 0!==e)return e.exports;let a=o[t]={exports:{}};return i[t](a,a.exports,r),a.exports}r.n=t=>{let e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{if(Array.isArray(e))for(var i=0;i<e.length;){var o=e[i++],a=e[i++];r.o(t,o)?0===a&&i++:0===a?Object.defineProperty(t,o,{enumerable:!0,value:e[i++]}):Object.defineProperty(t,o,{enumerable:!0,get:a})}else for(var o in e)r.o(e,o)&&!r.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let a={};r.d(a,{default:()=>E});var n=r(944),l=r.n(n);let s=function(t,e){let{animatableAttribs:i,onComplete:o,css:r,renderer:a}=e,n=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?a.text():"image"===e.shapeType?a.image(e.imageUrl||"").attr(e.shapeArgs||{}):a[e.shapeType](e.shapeArgs||{}),l.add(e.group)),r&&l.css(r),l.attr(e.attribs).animate(i,!e.isNew&&n,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=r(512),d=r.n(h);let{column:{prototype:{pointClass:p}}}=d().seriesTypes;class u extends p{isValid(){return!0}}(0,n.extend)(u.prototype,{weight:1});let{deg2rad:g}=l();function c(t,e){return!(e.left>t.right||e.right<t.left||e.top>t.bottom||e.bottom<t.top)}function m(t){let e,i=t.axes||[];return i.length||(i=[],(e=t.concat([t[0]])).reduce((t,e)=>{let o,r,a=(o=e[0]-t[0],[[-(r=e[1]-t[1]),o],[r,-o]])[0];return(0,n.find)(i,t=>t[0]===a[0]&&t[1]===a[1])||i.push(a),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=m(t),o=m(e),r=i.concat(o);return!(0,n.find)(r,i=>{let o,r;return o=f(t,i),!!((r=f(e,i)).min>o.max||r.max<o.min)})}function y(t,e){let i=4*t,o=Math.ceil((Math.sqrt(i)-1)/2),r=2*o+1,a=Math.pow(r,2),n=!1;return r-=1,t<=1e4&&("boolean"==typeof n&&i>=a-r&&(n={x:o-(a-i),y:-o}),a-=r,"boolean"==typeof n&&i>=a-r&&(n={x:-o,y:-o+(a-i)}),a-=r,"boolean"==typeof n&&(n=i>=a-r?{x:-o+(a-i),y:o}:{x:o,y:o-(a-i-r)}),n.x*=5,n.y*=5),n}function b(t,e){let i=Math.pow(10,(0,n.isNumber)(e)?e:14);return Math.round(t*i)/i}function M(t,e){let i=t[0],o=t[1],r=-(g*e),a=Math.cos(r),n=Math.sin(r);return[b(i*a-o*n),b(i*n+o*a)]}function w(t,e,i){let o=M([t[0]-e[0],t[1]-e[1]],i);return[o[0]+e[0],o[1]+e[1]]}let{noop:S}=l(),{column:A}=d().seriesTypes,{archimedeanSpiral:P,extendPlayingField:F,getBoundingBoxFromPolygon:N,getPlayingField:X,getPolygon:v,getRandomPosition:T,getRotation:O,getScale:z,getSpiral:j,intersectionTesting:Y,isPolygonsColliding:H,rectangularSpiral:R,rotate2DToOrigin:B,rotate2DToPoint:C,squareSpiral:W,updateFieldBoundaries:_}={archimedeanSpiral:function(t,e){let i=e.field,o=i.width*i.width+i.height*i.height,r=.8*t,a=!1;return t<=1e4&&(Math.min(Math.abs((a={x:r*Math.cos(r),y:r*Math.sin(r)}).x),Math.abs(a.y))<o||(a=!1)),a},extendPlayingField:function(t,e){let i,o,r,a,l,s;return(0,n.isObject)(t)&&(0,n.isObject)(e)?(i=e.bottom-e.top,o=e.right-e.left,l=o*(r=t.ratioX)>i*(a=t.ratioY)?o:i,s=(0,n.merge)(t,{width:t.width+l*r*2,height:t.height+l*a*2})):s=t,s},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}),r=Math.max(o.maxHeight,o.maxWidth,.85*Math.sqrt(o.area)),a=t>e?t/e:1,n=e>t?e/t:1;return{width:r*a,height:r*n,ratioX:a,ratioY:n}},getPolygon:function(t,e,i,o,r){let a=[t,e],n=t-i/2,l=t+i/2,s=e-o/2,h=e+o/2;return[[n,s],[l,s],[l,h],[n,h]].map(function(t){return w(t,a,-r)})},getRandomPosition:function(t){return Math.round(t*(Math.random()+.5)/2)},getRotation:function(t,e,i,o){let r=!1,a;return(0,n.isNumber)(t)&&(0,n.isNumber)(e)&&(0,n.isNumber)(i)&&(0,n.isNumber)(o)&&t>0&&e>-1&&o>i&&(a=(o-i)/(t-1||1),r=i+e%t*a),r},getScale:function(t,e,i){let o=2*Math.max(Math.abs(i.top),Math.abs(i.bottom)),r=2*Math.max(Math.abs(i.left),Math.abs(i.right));return Math.min(r>0?1/r*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,r,a,l,s,h=e.placed,d=e.field,p=e.rectangle,u=e.polygon,g=e.spiral,m=t.rect=(0,n.extend)({},p),f=1,y={x:0,y:0};for(t.polygon=u,t.rotation=e.rotation;!1!==y&&(i=t.rect,o=t.polygon,r=t.lastCollidedWith,a=function(e){let r=c(i,e.rect);return r&&(t.rotation%90||e.rotation%90)&&(r=x(o,e.polygon)),r},l=!1,r&&!(l=a(r))&&delete t.lastCollidedWith,!l&&(l=!!(0,n.find)(h,function(e){let i=a(e);return i&&(t.lastCollidedWith=e),i})),l||!((s={left:-(d.width/2),right:d.width/2,top:-(d.height/2),bottom:d.height/2}).left<m.left&&s.right>m.right&&s.top<m.top&&s.bottom>m.bottom));)y=g(f),(0,n.isObject)(y)&&(m.left=p.left+y.x,m.right=p.right+y.x,m.top=p.top+y.y,m.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,u)),f++;return y},isPolygonsColliding:x,isRectanglesIntersecting:c,rectangularSpiral:function(t,e){let i=y(t,e),o=e.field;return i&&(i.x*=o.ratioX,i.y*=o.ratioY),i},rotate2DToOrigin:M,rotate2DToPoint:w,squareSpiral:y,updateFieldBoundaries:function(t,e){return(!(0,n.isNumber)(t.left)||t.left>e.left)&&(t.left=e.left),(!(0,n.isNumber)(t.right)||t.right<e.right)&&(t.right=e.right),(!(0,n.isNumber)(t.top)||t.top>e.top)&&(t.top=e.top),(!(0,n.isNumber)(t.bottom)||t.bottom<e.bottom)&&(t.bottom=e.bottom),t}};class D extends A{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=(0,n.isNumber)(t)?t:0,r=(0,n.isNumber)(e)?e:1;return Math.floor(Math.max((0,n.isNumber)(i)?i:1,o*r))}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,r=this.group,a=this.options,l=a.animation,h=a.allowExtendPlayingField,d=o.renderer,p=[],u=this.placementStrategy[a.placementStrategy],g=a.rotation,c=this.points.map(function(t){return t.weight}),m=Math.max.apply(null,c),f=this.points.concat().sort((t,e)=>e.weight-t.weight),x=d.text().add(r),y;for(let t of(this.group.attr({scaleX:1,scaleY:1}),f)){let e=1/m*t.weight,i=this.deriveFontSize(e,a.maxFontSize,a.minFontSize),o=(0,n.extend)({fontSize:i+"px"},a.style);x.css(o).attr({x:0,y:0,text:t.name});let r=x.getBBox(!0);t.dimensions={height:r.height,width:r.width}}y=X(e.len,i.len,f);let b=j(this.spirals[a.spiral],{field:y});for(let e of f){let i=1/m*e.weight,o=this.deriveFontSize(i,a.maxFontSize,a.minFontSize),c=(0,n.extend)({fontSize:o+"px"},a.style),x=u(e,{data:f,field:y,placed:p,rotation:g}),M=(0,n.extend)(this.pointAttribs(e,e.selected&&"select"),{align:"center","alignment-baseline":"middle","dominant-baseline":"middle",x:x.x,y:x.y,text:e.name,rotation:(0,n.isNumber)(x.rotation)?x.rotation:void 0}),w=v(x.x,x.y,e.dimensions.width,e.dimensions.height,x.rotation),S=N(w),A=Y(e,{rectangle:S,polygon:w,field:y,placed:p,spiral:b,rotation:x.rotation}),P;!A&&h&&(y=F(y,S),A=Y(e,{rectangle:S,polygon:w,field:y,placed:p,spiral:b,rotation:x.rotation})),(0,n.isObject)(A)?(M.x=(M.x||0)+A.x,M.y=(M.y||0)+A.y,S.left+=A.x,S.right+=A.x,S.top+=A.y,S.bottom+=A.y,y=_(y,S),p.push(e),e.isNull=!1,e.isInside=!0):e.isNull=!0,l&&(P={x:M.x,y:M.y},t?(delete M.x,delete M.y):(M.x=0,M.y=0)),s(e,{animatableAttribs:P,attribs:M,css:c,group:r,renderer:d,shapeArgs:void 0,shapeType:"text"})}x=x.destroy(),this.defaultScale=z(e.len,i.len,y),this.field=y,this.group.attr({scaleX:this.defaultScale,scaleY:this.defaultScale})}hasData(){return(0,n.isObject)(this)&&!0===this.visible&&(0,n.isArray)(this.points)&&this.points.length>0}getPlotBox(t){let{chart:e,group:i,zooming:o}=this,{plotSizeX:r=0,plotSizeY:a=0,inverted:l}=e,s=this[l?"yAxis":"xAxis"],h=this[l?"xAxis":"yAxis"],d=s?s.len:e.plotWidth,p=h?h.len:e.plotHeight,u=s?s.left:e.plotLeft,g=h?h.top:e.plotTop,c=this.field,m=0,f=0,x=u+d/2,y=g+p/2,b=x,M=y,w=this.defaultScale||1,S=0,A=0;if(c&&(S=2*Math.max(Math.abs(c.top),Math.abs(c.bottom)),A=2*Math.max(Math.abs(c.left),Math.abs(c.right))),l&&([A,S]=[S,A]),i&&o){let e=u+Math.max(A*(w=Math.max(o.scale,this.defaultScale||1)),d)/2,l=g+Math.max(S*w,p)/2,s=w-(i.scaleX||1);m=s*((r-A)/2+o.zoomX*r-d/2),f=s*((a-S)/2+o.zoomY*a-p/2),"series"===t&&(o.x=Math.max(0,Math.min(1-o.width,o.x+o.panX/o.scale)),m+=o.panX*r,o.panX=0,o.y=Math.max(0,Math.min(1-o.height,o.y+o.panY/o.scale)),f+=o.panY*a,o.panY=0),(0,n.isNumber)(i.translateX)&&(0,n.isNumber)(i.translateY)&&(b=i.translateX,M=i.translateY),x=b-m,(y=M-f)>l?y=l:y<2*g+p-l&&(y=2*g+p-l),x>e?x=e:x<2*u+d-e&&(x=2*u+d-e)}return{translateX:x,translateY:y,scaleX:w,scaleY:w}}}D.defaultOptions=(0,n.merge)(A.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/>'}}),(0,n.extend)(D.prototype,{animate:S,animateDrilldown:S,animateDrillupFrom:S,isCartesian:!1,pointClass:u,setClip:S,placementStrategy:{random:function(t,e){let i=e.field,o=e.rotation;return{x:T(i.width)-i.width/2,y:T(i.height)-i.height/2,rotation:O(o.orientations,t.index,o.from,o.to)}},center:function(t,e){let i=e.rotation;return{x:0,y:0,rotation:O(i.orientations,t.index,i.from,i.to)}}},pointArrayMap:["weight"],spirals:{archimedean:P,rectangular:R,square:W},utils:{extendPlayingField:F,getRotation:O,isPolygonsColliding:H,rotate2DToOrigin:B,rotate2DToPoint:C}}),d().registerSeriesType("wordcloud",D);let E=l();return a.default})());