@lxlib/chart
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
16 lines (14 loc) • 5.52 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@antv/g2"),require("@lxlib/util"),require("rxjs"),require("rxjs/operators"),require("@angular/common"),require("ng-zorro-antd/core/outlet")):"function"==typeof define&&define.amd?define("@lxlib/chart/bar",["exports","@angular/core","@antv/g2","@lxlib/util","rxjs","rxjs/operators","@angular/common","ng-zorro-antd/core/outlet"],e):e(((t=t||self).lxlib=t.lxlib||{},t.lxlib.chart=t.lxlib.chart||{},t.lxlib.chart.bar={}),t.ng.core,t.g2,t.lxlib.util,t.rxjs,t.rxjs.operators,t.ng.common,t["ng-zorro-antd/core/outlet"])}(this,(function(t,e,n,r,i,o,a,l){"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 u(t,e,n,r){var i,o=arguments.length,a=o<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--)(i=t[l])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function c(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function s(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function h(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t}var p=function(){function t(t){this.ngZone=t,this.delay=0,this.color="rgba(24, 144, 255, 0.85)",this.height=0,this.padding="auto",this.data=[],this.autoLabel=!0,this.interaction="none"}return t.prototype.getHeight=function(){return this.title?this.height-41:this.height},t.prototype.install=function(){var t=this,e=this.node,r=this.padding,i=this.interaction,o=e.nativeElement,a=this.chart=new n.Chart({container:o,autoFit:!0,height:this.getHeight(),padding:r});this.updatelabel(),a.axis("y",{title:null,line:null,tickLine:null}),a.scale({x:{type:"cat"},y:{min:0}}),a.tooltip({showTitle:!1}),"none"!==i&&a.interaction(i),a.legend(!1),a.interval().position("x*y").color("x*y",(function(e,n){var r=t.data.find((function(t){return t.x===e&&t.y===n}));return r&&r.color?r.color:t.color})).tooltip("x*y",(function(t,e){return{name:t,value:e}})),this.attachChart()},t.prototype.attachChart=function(){var t=this.chart,e=this.padding,n=this.data;if(t&&n&&!(n.length<=0)){this.installResizeEvent();var r=this.getHeight();t.height!==r&&(t.height=r),t.padding=e,t.data(n),t.render()}},t.prototype.updatelabel=function(){var t=this.node,e=this.data,n=this.chart,r=t.nativeElement.clientWidth,i=30*e.length;n.axis("x",r>i).render()},t.prototype.installResizeEvent=function(){var t=this;this.autoLabel&&!this.resize$&&(this.resize$=i.fromEvent(window,"resize").pipe(o.filter((function(){return!!t.chart})),o.debounceTime(200)).subscribe((function(){return t.ngZone.runOutsideAngular((function(){return t.updatelabel()}))})))},t.prototype.ngOnInit=function(){var t=this;this.ngZone.runOutsideAngular((function(){return setTimeout((function(){return t.install()}),t.delay)}))},t.prototype.ngOnChanges=function(){var t=this;this.ngZone.runOutsideAngular((function(){return t.attachChart()}))},t.prototype.ngOnDestroy=function(){var t=this;this.resize$&&this.resize$.unsubscribe(),this.chart&&this.ngZone.runOutsideAngular((function(){return t.chart.destroy()}))},t.decorators=[{type:e.Component,args:[{selector:"g2-bar",exportAs:"g2Bar",template:'<ng-container *nzStringTemplateOutlet="title">\n <h4 style="margin-bottom:20px">{{title}}</h4>\n</ng-container>\n<div #container></div>\n',host:{"[style.height.px]":"height"},preserveWhitespaces:!1,changeDetection:e.ChangeDetectionStrategy.OnPush,encapsulation:e.ViewEncapsulation.None}]}],t.ctorParameters=function(){return[{type:e.NgZone}]},t.propDecorators={node:[{type:e.ViewChild,args:["container",{static:!0}]}],delay:[{type:e.Input}],title:[{type:e.Input}],color:[{type:e.Input}],height:[{type:e.Input}],padding:[{type:e.Input}],data:[{type:e.Input}],autoLabel:[{type:e.Input}],interaction:[{type:e.Input}]},u([r.InputNumber(),c("design:type",Object)],t.prototype,"delay",void 0),u([r.InputNumber(),c("design:type",Object)],t.prototype,"height",void 0),u([r.InputBoolean(),c("design:type",Object)],t.prototype,"autoLabel",void 0),t}();var d=[p],g=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[a.CommonModule,r.LxlibUtilModule,l.NzOutletModule],declarations:h(d),exports:h(d)}]}],t}();t.G2BarComponent=p,t.G2BarModule=g,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=bar.umd.min.js.map