@lxlib/chart
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
2 lines • 4.75 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@antv/data-set"),require("@antv/g2"),require("@lxlib/util"),require("rxjs"),require("rxjs/operators"),require("@angular/common")):"function"==typeof define&&define.amd?define("@lxlib/chart/tag-cloud",["exports","@angular/core","@antv/data-set","@antv/g2","@lxlib/util","rxjs","rxjs/operators","@angular/common"],e):e(((t=t||self).lxlib=t.lxlib||{},t.lxlib.chart=t.lxlib.chart||{},t.lxlib.chart["tag-cloud"]={}),t.ng.core,t.DataSet,t.g2,t.lxlib.util,t.rxjs,t.rxjs.operators,t.ng.common)}(this,(function(t,e,n,r,o,i,a,l){"use strict";n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;var u=function(){return(u=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function c(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var l=t.length-1;l>=0;l--)(o=t[l])&&(a=(i<3?o(a):i>3?o(e,n,a):o(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a}function s(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function h(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function p(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(h(arguments[e]));return t}var f=function(){function t(t,e){this.el=t,this.ngZone=e,this.delay=0,this.height=100,this.padding=0,this.data=[]}return t.prototype.initTagCloud=function(){r.registerShape("point","cloud",{draw:function(t,e){var n=t.data,o=e.addShape("text",{attrs:u(u(u({},t.defaultStyle),t.style),{fontSize:n.size,text:n.text,textAlign:"center",fontFamily:n.font,fill:t.color,textBaseline:"Alphabetic",x:t.x,y:t.y})});return n.rotate&&r.Util.rotate(o,n.rotate*Math.PI/180),o}})},t.prototype.install=function(){var t=this.el,e=this.padding,n=this.height,o=this.chart=new r.Chart({container:t.nativeElement,padding:e,height:n});o.legend(!1),o.axis(!1),o.tooltip({showTitle:!1,showMarkers:!1}),o.coordinate().reflect("x"),o.point().position("x*y").color("category").shape("cloud").tooltip("value*category"),o.interaction("element-active"),this.attachChart()},t.prototype.attachChart=function(){var t=this.chart,e=this.height,r=this.padding,o=this.data;if(t&&o&&!(o.length<=0)){t.height=e,t.padding=r,t.forceFit();var i=(new n.View).source(o),a=i.range("value"),l=a[0],u=a[1];i.transform({type:"tag-cloud",fields:["x","value"],size:[t.width,t.height],padding:"number"==typeof r?r:void 0,timeInterval:5e3,rotate:function(){var t=~~(4*Math.random())%4;return 2===t&&(t=0),90*t},fontSize:function(t){return t.value?(t.value-l)/(u-l)*56+24:0}}),t.scale({x:{nice:!1},y:{nice:!1}}),t.changeData(i.rows),t.render()}},t.prototype._attachChart=function(){var t=this;this.ngZone.runOutsideAngular((function(){return t.attachChart()}))},t.prototype.installResizeEvent=function(){var t=this;this.resize$=i.fromEvent(window,"resize").pipe(a.filter((function(){return!!t.chart})),a.debounceTime(200)).subscribe((function(){return t._attachChart()}))},t.prototype.ngOnInit=function(){var t=this;this.initTagCloud(),this.installResizeEvent(),this.ngZone.runOutsideAngular((function(){return setTimeout((function(){return t.install()}),t.delay)}))},t.prototype.ngOnChanges=function(){this._attachChart()},t.prototype.ngOnDestroy=function(){var t=this;this.resize$.unsubscribe(),this.chart&&this.ngZone.runOutsideAngular((function(){return t.chart.destroy()}))},t.decorators=[{type:e.Component,args:[{selector:"g2-tag-cloud",exportAs:"g2TagCloud",template:"",host:{"[style.height.px]":"height"},preserveWhitespaces:!1,changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:e.ElementRef},{type:e.NgZone}]},t.propDecorators={delay:[{type:e.Input}],height:[{type:e.Input}],padding:[{type:e.Input}],data:[{type:e.Input}]},c([o.InputNumber(),s("design:type",Object)],t.prototype,"delay",void 0),c([o.InputNumber(),s("design:type",Object)],t.prototype,"height",void 0),t}();var d=[f],g=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[l.CommonModule,o.LxlibUtilModule],declarations:p(d),exports:p(d)}]}],t}();t.G2TagCloudComponent=f,t.G2TagCloudModule=g,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=tag-cloud.umd.min.js.map