@lxlib/chart
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
16 lines (14 loc) • 6.4 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/core"),require("@antv/g2"),require("@lxlib/util"),require("@angular/common"),require("ng-zorro-antd/core/outlet"),require("ng-zorro-antd/grid")):"function"==typeof define&&define.amd?define("@lxlib/chart/radar",["exports","@angular/core","@antv/g2","@lxlib/util","@angular/common","ng-zorro-antd/core/outlet","ng-zorro-antd/grid"],t):t(((e=e||self).lxlib=e.lxlib||{},e.lxlib.chart=e.lxlib.chart||{},e.lxlib.chart.radar={}),e.ng.core,e.g2,e.lxlib.util,e.ng.common,e["ng-zorro-antd/core/outlet"],e["ng-zorro-antd/grid"])}(this,(function(e,t,n,r,i,o,a){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function l(e,t,n,r){var i,o=arguments.length,a=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(a=(o<3?i(a):o>3?i(t,n,a):i(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function u(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function d(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(u(arguments[t]));return e}var s=function(){function e(e,t){this.cdr=e,this.ngZone=t,this.legendData=[],this.delay=0,this.height=0,this.padding=[44,30,16,30],this.hasLegend=!0,this.tickCount=4,this.data=[],this.colors=["#1890FF","#FACC14","#2FC25B","#8543E0","#F04864","#13C2C2","#fa8c16","#a0d911"]}return e.prototype.getHeight=function(){return this.height-(this.hasLegend?80:22)},e.prototype.install=function(){var e=this,t=this.node,r=this.padding,i=this.chart=new n.Chart({container:t.nativeElement,autoFit:!0,height:this.getHeight(),padding:r});i.coordinate("polar"),i.legend(!1),i.axis("label",{line:null,label:{offset:8,style:{fill:"rgba(0, 0, 0, .65)"}},grid:{line:{style:{stroke:"#e9e9e9",lineWidth:1,lineDash:[0,0]}}}}),i.axis("value",{grid:{line:{type:"polygon",style:{stroke:"#e9e9e9",lineWidth:1,lineDash:[0,0]}}},label:{style:{fill:"rgba(0, 0, 0, .65)"}}}),i.filter("name",(function(t){var n=e.legendData.find((function(e){return e.name===t}));return!n||!1!==n.checked})),i.line().position("label*value"),i.point().position("label*value").shape("circle").size(3),i.render(),this.attachChart()},e.prototype.attachChart=function(){var e=this,t=this,n=t.chart,r=t.padding,i=t.data,o=t.colors,a=t.tickCount;!n||!i||i.length<=0||(n.height=this.getHeight(),n.padding=r,n.scale({value:{min:0,tickCount:a}}),n.geometries.forEach((function(e){return e.color("name",o)})),n.changeData(i),this.ngZone.run((function(){return e.genLegend()})))},e.prototype.genLegend=function(){var e=this.hasLegend,t=this.cdr,n=this.chart;e&&(this.legendData=n.geometries[0].dataArray.map((function(e){return{name:e[0]._origin.name,color:e[0].color,checked:!0,value:e.reduce((function(e,t){return e+t._origin.value}),0)}})),t.detectChanges())},e.prototype._click=function(e){var t=this.legendData,n=this.chart;t[e].checked=!t[e].checked,n.render()},e.prototype.ngOnInit=function(){var e=this;this.ngZone.runOutsideAngular((function(){return setTimeout((function(){return e.install()}),e.delay)}))},e.prototype.ngOnChanges=function(){var e=this;this.legendData.forEach((function(e){return e.checked=!0})),this.ngZone.runOutsideAngular((function(){return e.attachChart()}))},e.prototype.ngOnDestroy=function(){var e=this;this.chart&&this.ngZone.runOutsideAngular((function(){return e.chart.destroy()}))},e.decorators=[{type:t.Component,args:[{selector:"g2-radar",exportAs:"g2Radar",template:'<ng-container *nzStringTemplateOutlet="title">\n <h4>{{title}}</h4>\n</ng-container>\n<div #container></div>\n<div nz-row\n class="g2-radar__legend"\n *ngIf="hasLegend">\n <div nz-col\n [nzSpan]="24 / legendData.length"\n *ngFor="let i of legendData; let idx = index"\n (click)="_click(idx)"\n class="g2-radar__legend-item">\n <i class="g2-radar__legend-dot"\n [ngStyle]="{\'background-color\': !i.checked ? \'#aaa\' : i.color}"></i>\n {{i.name}}\n <h6 class="g2-radar__legend-title">{{i.value}}</h6>\n </div>\n</div>\n',host:{"[style.height.px]":"height","[class.g2-radar]":"true"},preserveWhitespaces:!1,changeDetection:t.ChangeDetectionStrategy.OnPush,encapsulation:t.ViewEncapsulation.None}]}],e.ctorParameters=function(){return[{type:t.ChangeDetectorRef},{type:t.NgZone}]},e.propDecorators={node:[{type:t.ViewChild,args:["container",{static:!0}]}],delay:[{type:t.Input}],title:[{type:t.Input}],height:[{type:t.Input}],padding:[{type:t.Input}],hasLegend:[{type:t.Input}],tickCount:[{type:t.Input}],data:[{type:t.Input}],colors:[{type:t.Input}]},l([r.InputNumber(),c("design:type",Object)],e.prototype,"delay",void 0),l([r.InputNumber(),c("design:type",Object)],e.prototype,"height",void 0),l([r.InputBoolean(),c("design:type",Object)],e.prototype,"hasLegend",void 0),l([r.InputNumber(),c("design:type",Object)],e.prototype,"tickCount",void 0),e}();var g=[s],h=function(){function e(){}return e.decorators=[{type:t.NgModule,args:[{imports:[i.CommonModule,r.LxlibUtilModule,a.NzGridModule,o.NzOutletModule],declarations:d(g),exports:d(g)}]}],e}();e.G2RadarComponent=s,e.G2RadarModule=h,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=radar.umd.min.js.map