wordcloud.js 7.85 KB
/*
 Highcharts JS v6.2.0 (2018-10-17)

 (c) 2016 Highsoft AS
 Authors: Jon Arild Nygard

 License: www.highcharts.com/license
*/
(function(l){"object"===typeof module&&module.exports?module.exports=l:"function"===typeof define&&define.amd?define(function(){return l}):l(Highcharts)})(function(l){var B=function(){return function(a){var h=this,g=h.graphic,A=a.animate,u=a.attr,q=a.onComplete,m=a.css,r=a.group,l=a.renderer,p=a.shapeArgs;a=a.shapeType;h.shouldDraw()?(g||(h.graphic=g=l[a](p).add(r)),g.css(m).attr(u).animate(A,void 0,q)):g&&g.animate(A,void 0,function(){h.graphic=g=g.destroy();"function"===typeof q&&q()});g&&g.addClass(h.getClassName(),
!0)}}(),F=function(a){var h=a.deg2rad,g=a.find,l=a.isArray,u=a.isNumber,q=a.map,m=a.reduce,r=function(b,c){c=u(c)?c:14;c=Math.pow(10,c);return Math.round(b*c)/c},y=function(b,c){var k=c[0]-b[0];b=c[1]-b[1];return[[-b,k],[b,-k]]},p=function(b,c){b=q(b,function(b){return b[0]*c[0]+b[1]*c[1]});return{min:Math.min.apply(this,b),max:Math.max.apply(this,b)}},v=function(b,c){var k=b[0];b=b[1];var a=h*-c;c=Math.cos(a);a=Math.sin(a);return[r(k*c-b*a),r(k*a+b*c)]},z=function(b,c,a){b=v([b[0]-c[0],b[1]-c[1]],
a);return[b[0]+c[0],b[1]+c[1]]},C=function(b){var c,a=b.axes;l(a)||(a=[],c=c=b.concat([b[0]]),m(c,function(c,b){var k=y(c,b)[0];g(a,function(c){return c[0]===k[0]&&c[1]===k[1]})||a.push(k);return b}),b.axes=a);return a},E=function(b,c){b=C(b);c=C(c);return b.concat(c)};return{getBoundingBoxFromPolygon:function(b){return m(b,function(c,b){var a=b[0];b=b[1];c.left=Math.min(a,c.left);c.right=Math.max(a,c.right);c.bottom=Math.max(b,c.bottom);c.top=Math.min(b,c.top);return c},{left:Number.MAX_VALUE,right:-Number.MAX_VALUE,
bottom:-Number.MAX_VALUE,top:Number.MAX_VALUE})},getPolygon:function(b,c,a,g,m){var k=[b,c],l=b-a/2;b+=a/2;a=c-g/2;c+=g/2;return q([[l,a],[b,a],[b,c],[l,c]],function(b){return z(b,k,-m)})},isPolygonsColliding:function(b,c){var a=E(b,c);return!g(a,function(a){var g=p(b,a);a=p(c,a);return!!(a.min>g.max||a.max<g.min)})},movePolygon:function(b,a,g){return q(g,function(c){return[c[0]+b,c[1]+a]})},rotate2DToOrigin:v,rotate2DToPoint:z}}(l);(function(a,l,g){var h=a.each,u=a.extend,q=a.isArray,m=a.isNumber,
r=a.isObject,y=a.map,p=a.merge,v=a.find,z=a.reduce,C=g.getBoundingBoxFromPolygon,E=g.getPolygon,b=g.isPolygonsColliding,c=g.movePolygon,k=a.Series,B=function(e,d){var f=!1,a=e.rect,c=e.polygon,H=e.lastCollidedWith,g=function(d){var f;f=d.rect;(f=!(f.left>a.right||f.right<a.left||f.top>a.bottom||f.bottom<a.top))&&(e.rotation%90||d.roation%90)&&(f=b(c,d.polygon));return f};H&&((f=g(H))||delete e.lastCollidedWith);f||(f=!!v(d,function(d){var f=g(d);f&&(e.lastCollidedWith=d);return f}));return f},G=function(e){var d=
4*e,f=Math.ceil((Math.sqrt(d)-1)/2),a=2*f+1,b=Math.pow(a,2),c=!1,a=a-1;1E4>=e&&("boolean"===typeof c&&d>=b-a&&(c={x:f-(b-d),y:-f}),b-=a,"boolean"===typeof c&&d>=b-a&&(c={x:-f,y:-f+(b-d)}),b-=a,"boolean"===typeof c&&(c=d>=b-a?{x:-f+(b-d),y:f}:{x:f,y:f-(b-d-a)}),c.x*=5,c.y*=5);return c},F=function(e,d,f){var a=2*Math.max(Math.abs(f.top),Math.abs(f.bottom));f=2*Math.max(Math.abs(f.left),Math.abs(f.right));return Math.min(0<f?1/f*e:1,0<a?1/a*d:1)},K=function(e,d,f){f=z(f,function(d,e){e=e.dimensions;
var f=Math.max(e.width,e.height);d.maxHeight=Math.max(d.maxHeight,e.height);d.maxWidth=Math.max(d.maxWidth,e.width);d.area+=f*f;return d},{maxHeight:0,maxWidth:0,area:0});f=Math.max(f.maxHeight,f.maxWidth,.85*Math.sqrt(f.area));var a=e>d?e/d:1;e=d>e?d/e:1;return{width:f*a,height:f*e,ratioX:a,ratioY:e}},x=function(e,d,f,a){var c=!1;m(e)&&m(d)&&m(f)&&m(a)&&-1<e&&-1<d&&a>f&&(c=f+d%e*((a-f)/(e-1)));return c},L=function(e,d){var f=y(Array(1E4),function(f,a){return e(a+1,d)});return function(d){return 1E4>=
d?f[d-1]:!1}},M=function(e,d){var f=d.width/2,a=-(d.height/2),c=d.height/2;return!(-(d.width/2)<e.left&&f>e.right&&a<e.top&&c>e.bottom)},I=function(e,d){var f=d.placed,a=d.field,b=d.rectangle,g=d.polygon,m=d.spiral,l=1,k={x:0,y:0},h=e.rect=u({},b);e.polygon=g;for(e.rotation=d.rotation;!1!==k&&(B(e,f)||M(h,a));)k=m(l),r(k)&&(h.left=b.left+k.x,h.right=b.right+k.x,h.top=b.top+k.y,h.bottom=b.bottom+k.y,e.polygon=c(k.x,k.y,g)),l++;return k},J=function(e,d){var a,b,c;r(e)&&r(d)&&(a=d.bottom-d.top,b=d.right-
d.left,d=e.ratioX,c=e.ratioY,a=b*d>a*c?b:a,e=p(e,{width:e.width+a*d*2,height:e.height+a*c*2}));return e};a.seriesType("wordcloud","column",{allowExtendPlayingField:!0,animation:{duration:500},borderWidth:0,clip:!1,colorByPoint:!0,minFontSize:1,maxFontSize:25,placementStrategy:"center",rotation:{from:0,orientations:2,to:90},showInLegend:!1,spiral:"rectangular",style:{fontFamily:"sans-serif",fontWeight:"900"},tooltip:{followPointer:!0,pointFormat:'\x3cspan style\x3d"color:{point.color}"\x3e\u25cf\x3c/span\x3e {series.name}: \x3cb\x3e{point.weight}\x3c/b\x3e\x3cbr/\x3e'}},
{animate:k.prototype.animate,bindAxes:function(){var a={endOnTick:!1,gridLineWidth:0,lineWidth:0,maxPadding:0,startOnTick:!1,title:null,tickPositions:[]};k.prototype.bindAxes.call(this);u(this.yAxis.options,a);u(this.xAxis.options,a)},deriveFontSize:function(a,d,f){a=m(a)?a:0;d=m(d)?d:1;f=m(f)?f:1;return Math.floor(Math.max(f,a*d))},drawPoints:function(){var a=this,d=a.hasRendered,f=a.xAxis,b=a.yAxis,c=a.group,g=a.options,k=g.animation,l=g.allowExtendPlayingField,q=a.chart.renderer,p=q.text().add(c),
v=[],z=a.placementStrategy[g.placementStrategy],y,B=g.rotation,x=a.points.map(function(a){return a.weight}),A=Math.max.apply(null,x),D=a.points.sort(function(a,d){return d.weight-a.weight}),t;h(D,function(d){var b=a.deriveFontSize(1/A*d.weight,g.maxFontSize,g.minFontSize),b=u({fontSize:b+"px"},g.style);p.css(b).attr({x:0,y:0,text:d.name});b=p.getBBox(!0);d.dimensions={height:b.height,width:b.width}});t=K(f.len,b.len,D);y=L(a.spirals[g.spiral],{field:t});h(D,function(b){var f=a.deriveFontSize(1/A*
b.weight,g.maxFontSize,g.minFontSize),f=u({fontSize:f+"px",fill:b.color},g.style),e=z(b,{data:D,field:t,placed:v,rotation:B}),h={align:"center","alignment-baseline":"middle",x:e.x,y:e.y,text:b.name,rotation:e.rotation},p=E(e.x,e.y,b.dimensions.width,b.dimensions.height,e.rotation),n=C(p),w=I(b,{rectangle:n,polygon:p,field:t,placed:v,spiral:y,rotation:e.rotation}),x;!w&&l&&(t=J(t,n),w=I(b,{rectangle:n,polygon:p,field:t,placed:v,spiral:y,rotation:e.rotation}));if(r(w)){h.x+=w.x;h.y+=w.y;n.left+=w.x;
n.right+=w.x;n.top+=w.y;n.bottom+=w.y;e=t;if(!m(e.left)||e.left>n.left)e.left=n.left;if(!m(e.right)||e.right<n.right)e.right=n.right;if(!m(e.top)||e.top>n.top)e.top=n.top;if(!m(e.bottom)||e.bottom<n.bottom)e.bottom=n.bottom;t=e;v.push(b);b.isNull=!1}else b.isNull=!0;k&&(x={x:h.x,y:h.y},d?(delete h.x,delete h.y):(h.x=0,h.y=0));b.draw({animate:x,attr:h,css:f,group:c,renderer:q,shapeArgs:void 0,shapeType:"text"})});p=p.destroy();f=F(f.len,b.len,t);a.group.attr({scaleX:f,scaleY:f})},hasData:function(){return r(this)&&
!0===this.visible&&q(this.points)&&0<this.points.length},placementStrategy:{random:function(a,d){var b=d.field;d=d.rotation;return{x:Math.round(b.width*(Math.random()+.5)/2)-b.width/2,y:Math.round(b.height*(Math.random()+.5)/2)-b.height/2,rotation:x(d.orientations,a.index,d.from,d.to)}},center:function(a,b){b=b.rotation;return{x:0,y:0,rotation:x(b.orientations,a.index,b.from,b.to)}}},pointArrayMap:["weight"],spirals:{archimedean:function(a,b){var d=b.field;b=!1;var d=d.width*d.width+d.height*d.height,
e=.8*a;1E4>=a&&(b={x:e*Math.cos(e),y:e*Math.sin(e)},Math.min(Math.abs(b.x),Math.abs(b.y))<d||(b=!1));return b},rectangular:function(a,b){a=G(a,b);b=b.field;a&&(a.x*=b.ratioX,a.y*=b.ratioY);return a},square:G},utils:{extendPlayingField:J,getRotation:x,isPolygonsColliding:b,rotate2DToOrigin:g.rotate2DToOrigin,rotate2DToPoint:g.rotate2DToPoint},getPlotBox:function(){var a=this.chart,b=a.inverted,c=this[b?"yAxis":"xAxis"],b=this[b?"xAxis":"yAxis"];return{translateX:(c?c.left:a.plotLeft)+(c?c.len:a.plotWidth)/
2,translateY:(b?b.top:a.plotTop)+(b?b.len:a.plotHeight)/2,scaleX:1,scaleY:1}}},{draw:l,shouldDraw:function(){return!this.isNull},weight:1})})(l,B,F)});
//# sourceMappingURL=wordcloud.js.map