wordcloud.js 8.1 KB

12345678910111213141516171819202122232425
  1. /*
  2. Highcharts JS v7.0.2 (2019-01-17)
  3. (c) 2016-2019 Highsoft AS
  4. Authors: Jon Arild Nygard
  5. License: www.highcharts.com/license
  6. */
  7. (function(h){"object"===typeof module&&module.exports?(h["default"]=h,module.exports=h):"function"===typeof define&&define.amd?define(function(){return h}):h("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(h){var y=function(){return function(f){var v=this,k=v.graphic,h=f.animatableAttribs,t=f.onComplete,w=f.css,A=f.renderer;v.shouldDraw()?(k||(v.graphic=k=A[f.shapeType](f.shapeArgs).add(f.group)),k.css(w).attr(f.attribs).animate(h,f.isNew?!1:void 0,t)):k&&k.animate(h,void 0,function(){v.graphic=
  8. k=k.destroy();"function"===typeof t&&t()});k&&k.addClass(v.getClassName(),!0)}}(),C=function(f){var h=f.deg2rad,k=f.find,J=f.isArray,t=f.isNumber,w=function(a,b){b=t(b)?b:14;b=Math.pow(10,b);return Math.round(a*b)/b},A=function(a,b){var d=b[0]-a[0];a=b[1]-a[1];return[[-a,d],[a,-d]]},q=function(a,b){a=a.map(function(a){return a[0]*b[0]+a[1]*b[1]});return{min:Math.min.apply(this,a),max:Math.max.apply(this,a)}},E=function(a,b){var d=a[0];a=a[1];var m=h*-b;b=Math.cos(m);m=Math.sin(m);return[w(d*b-a*m),
  9. w(d*m+a*b)]},z=function(a,b,d){a=E([a[0]-b[0],a[1]-b[1]],d);return[a[0]+b[0],a[1]+b[1]]},B=function(a){var b,d=a.axes;J(d)||(d=[],b=b=a.concat([a[0]]),b.reduce(function(a,b){var m=A(a,b)[0];k(d,function(a){return a[0]===m[0]&&a[1]===m[1]})||d.push(m);return b}),a.axes=d);return d},G=function(a,b){a=B(a);b=B(b);return a.concat(b)};return{getBoundingBoxFromPolygon:function(a){return a.reduce(function(a,d){var b=d[0];d=d[1];a.left=Math.min(b,a.left);a.right=Math.max(b,a.right);a.bottom=Math.max(d,a.bottom);
  10. a.top=Math.min(d,a.top);return a},{left:Number.MAX_VALUE,right:-Number.MAX_VALUE,bottom:-Number.MAX_VALUE,top:Number.MAX_VALUE})},getPolygon:function(a,b,d,m,f){var k=[a,b],h=a-d/2;a+=d/2;d=b-m/2;b+=m/2;return[[h,d],[a,d],[a,b],[h,b]].map(function(a){return z(a,k,-f)})},isPolygonsColliding:function(a,b){var d=G(a,b);return!k(d,function(d){var f=q(a,d);d=q(b,d);return!!(d.min>f.max||d.max<f.min)})},movePolygon:function(a,b,d){return d.map(function(d){return[d[0]+a,d[1]+b]})},rotate2DToOrigin:E,rotate2DToPoint:z}}(h);
  11. (function(f,h,k){function v(e,c){var g=!1,a=e.rect,d=e.polygon,b=e.lastCollidedWith,f=function(c){var g;g=c.rect;(g=!(g.left>a.right||g.right<a.left||g.top>a.bottom||g.bottom<a.top))&&(e.rotation%90||c.roation%90)&&(g=D(d,c.polygon));return g};b&&((g=f(b))||delete e.lastCollidedWith);g||(g=!!C(c,function(c){var g=f(c);g&&(e.lastCollidedWith=c);return g}));return g}function t(e){var c=4*e,g=Math.ceil((Math.sqrt(c)-1)/2),a=2*g+1,b=Math.pow(a,2),d=!1,a=a-1;1E4>=e&&("boolean"===typeof d&&c>=b-a&&(d={x:g-
  12. (b-c),y:-g}),b-=a,"boolean"===typeof d&&c>=b-a&&(d={x:-g,y:-g+(b-c)}),b-=a,"boolean"===typeof d&&(d=c>=b-a?{x:-g+(b-c),y:g}:{x:g,y:g-(b-c-a)}),d.x*=5,d.y*=5);return d}function w(e,c,g){var a=2*Math.max(Math.abs(g.top),Math.abs(g.bottom));g=2*Math.max(Math.abs(g.left),Math.abs(g.right));return Math.min(0<g?1/g*e:1,0<a?1/a*c:1)}function A(e,c,g){g=g.reduce(function(e,c){c=c.dimensions;var a=Math.max(c.width,c.height);e.maxHeight=Math.max(e.maxHeight,c.height);e.maxWidth=Math.max(e.maxWidth,c.width);
  13. e.area+=a*a;return e},{maxHeight:0,maxWidth:0,area:0});g=Math.max(g.maxHeight,g.maxWidth,.85*Math.sqrt(g.area));var a=e>c?e/c:1;e=c>e?c/e:1;return{width:g*a,height:g*e,ratioX:a,ratioY:e}}function q(e,c,a,b){var g=!1;d(e)&&d(c)&&d(a)&&d(b)&&-1<e&&-1<c&&b>a&&(g=a+c%e*((b-a)/(e-1)));return g}function E(e,a){var c,b=[];for(c=1;1E4>c;c++)b.push(e(c,a));return function(e){return 1E4>=e?b[e-1]:!1}}function z(e,c){var a=c.width/2,b=-(c.height/2),d=c.height/2;return!(-(c.width/2)<e.left&&a>e.right&&b<e.top&&
  14. d>e.bottom)}function B(e,c){var g=c.placed,b=c.field,d=c.rectangle,f=c.polygon,k=c.spiral,h=1,p={x:0,y:0},n=e.rect=a({},d);e.polygon=f;for(e.rotation=c.rotation;!1!==p&&(v(e,g)||z(n,b));)p=k(h),m(p)&&(n.left=d.left+p.x,n.right=d.right+p.x,n.top=d.top+p.y,n.bottom=d.bottom+p.y,e.polygon=L(p.x,p.y,f)),h++;return p}function G(e,a){var c,b,d;m(e)&&m(a)&&(c=a.bottom-a.top,b=a.right-a.left,a=e.ratioX,d=e.ratioY,c=b*a>c*d?b:c,e=y(e,{width:e.width+c*a*2,height:e.height+c*d*2}));return e}var a=f.extend,b=
  15. f.isArray,d=f.isNumber,m=f.isObject,y=f.merge,F=f.noop,C=f.find,K=k.getBoundingBoxFromPolygon,M=k.getPolygon,D=k.isPolygonsColliding,L=k.movePolygon,I=f.Series;f.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'}},
  16. {animate:I.prototype.animate,animateDrilldown:F,animateDrillupFrom:F,bindAxes:function(){var e={endOnTick:!1,gridLineWidth:0,lineWidth:0,maxPadding:0,startOnTick:!1,title:null,tickPositions:[]};I.prototype.bindAxes.call(this);a(this.yAxis.options,e);a(this.xAxis.options,e)},pointAttribs:function(a,c){a=f.seriesTypes.column.prototype.pointAttribs.call(this,a,c);delete a.stroke;delete a["stroke-width"];return a},deriveFontSize:function(a,c,b){a=d(a)?a:0;c=d(c)?c:1;b=d(b)?b:1;return Math.floor(Math.max(b,
  17. a*c))},drawPoints:function(){var e=this,c=e.hasRendered,b=e.xAxis,f=e.yAxis,k=e.group,h=e.options,t=h.animation,v=h.allowExtendPlayingField,p=e.chart.renderer,n=p.text().add(k),q=[],z=e.placementStrategy[h.placementStrategy],y,C=h.rotation,F=e.points.map(function(a){return a.weight}),D=Math.max.apply(null,F),H=e.points.sort(function(a,c){return c.weight-a.weight}),u;H.forEach(function(c){var b=e.deriveFontSize(1/D*c.weight,h.maxFontSize,h.minFontSize),b=a({fontSize:b+"px"},h.style);n.css(b).attr({x:0,
  18. y:0,text:c.name});b=n.getBBox(!0);c.dimensions={height:b.height,width:b.width}});u=A(b.len,f.len,H);y=E(e.spirals[h.spiral],{field:u});H.forEach(function(b){var g=e.deriveFontSize(1/D*b.weight,h.maxFontSize,h.minFontSize),g=a({fontSize:g+"px"},h.style),f=z(b,{data:H,field:u,placed:q,rotation:C}),r=a(e.pointAttribs(b,b.selected&&"select"),{align:"center","alignment-baseline":"middle",x:f.x,y:f.y,text:b.name,rotation:f.rotation}),n=M(f.x,f.y,b.dimensions.width,b.dimensions.height,f.rotation),l=K(n),
  19. x=B(b,{rectangle:l,polygon:n,field:u,placed:q,spiral:y,rotation:f.rotation}),w;!x&&v&&(u=G(u,l),x=B(b,{rectangle:l,polygon:n,field:u,placed:q,spiral:y,rotation:f.rotation}));if(m(x)){r.x+=x.x;r.y+=x.y;l.left+=x.x;l.right+=x.x;l.top+=x.y;l.bottom+=x.y;f=u;if(!d(f.left)||f.left>l.left)f.left=l.left;if(!d(f.right)||f.right<l.right)f.right=l.right;if(!d(f.top)||f.top>l.top)f.top=l.top;if(!d(f.bottom)||f.bottom<l.bottom)f.bottom=l.bottom;u=f;q.push(b);b.isNull=!1}else b.isNull=!0;t&&(w={x:r.x,y:r.y},c?
  20. (delete r.x,delete r.y):(r.x=0,r.y=0));b.draw({animatableAttribs:w,attribs:r,css:g,group:k,renderer:p,shapeArgs:void 0,shapeType:"text"})});n=n.destroy();b=w(b.len,f.len,u);e.group.attr({scaleX:b,scaleY:b})},hasData:function(){return m(this)&&!0===this.visible&&b(this.points)&&0<this.points.length},placementStrategy:{random:function(a,b){var c=b.field;b=b.rotation;return{x:Math.round(c.width*(Math.random()+.5)/2)-c.width/2,y:Math.round(c.height*(Math.random()+.5)/2)-c.height/2,rotation:q(b.orientations,
  21. a.index,b.from,b.to)}},center:function(a,b){b=b.rotation;return{x:0,y:0,rotation:q(b.orientations,a.index,b.from,b.to)}}},pointArrayMap:["weight"],spirals:{archimedean:function(a,b){var c=b.field;b=!1;var c=c.width*c.width+c.height*c.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))<c||(b=!1));return b},rectangular:function(a,b){a=t(a,b);b=b.field;a&&(a.x*=b.ratioX,a.y*=b.ratioY);return a},square:t},utils:{extendPlayingField:G,getRotation:q,isPolygonsColliding:D,
  22. rotate2DToOrigin:k.rotate2DToOrigin,rotate2DToPoint:k.rotate2DToPoint},getPlotBox:function(){var a=this.chart,b=a.inverted,d=this[b?"yAxis":"xAxis"],b=this[b?"xAxis":"yAxis"];return{translateX:(d?d.left:a.plotLeft)+(d?d.len:a.plotWidth)/2,translateY:(b?b.top:a.plotTop)+(b?b.len:a.plotHeight)/2,scaleX:1,scaleY:1}}},{draw:h,shouldDraw:function(){return!this.isNull},weight:1})})(h,y,C)});
  23. //# sourceMappingURL=wordcloud.js.map