UNPKG

@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.27 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@antv/g2"),require("@lxlib/util"),require("@angular/common")):"function"==typeof define&&define.amd?define("@lxlib/chart/single-bar",["exports","@angular/core","@antv/g2","@lxlib/util","@angular/common"],e):e(((t=t||self).lxlib=t.lxlib||{},t.lxlib.chart=t.lxlib.chart||{},t.lxlib.chart["single-bar"]={}),t.ng.core,t.g2,t.lxlib.util,t.ng.common)}(this,(function(t,e,n,r,o){"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. ***************************************************************************** */var i=function(){return(i=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 a(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 l(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function u(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(u(arguments[e]));return t}var c=function(){function t(t,e){this.el=t,this.ngZone=e,this.delay=0,this.plusColor="#40a9ff",this.minusColor="#ff4d4f",this.height=60,this.barSize=30,this.min=0,this.max=100,this.value=0,this.line=!1,this.padding=0,this.textStyle={fontSize:12,color:"#595959"}}return t.prototype.install=function(){var t=this,e=t.el,r=t.height,o=t.padding,a=t.textStyle,l=t.line,u=t.format,p=this.chart=new n.Chart({container:e.nativeElement,autoFit:!0,height:r,padding:o});p.legend(!1),p.axis(!1),p.tooltip(!1),p.coordinate().transpose(),p.interval().position("1*value").label("value",(function(){return{formatter:u,style:i({},a)}})),l&&p.annotation().line({start:["50%","0%"],end:["50%","100%"],style:{stroke:"#e8e8e8",lineDash:[0,0]}}),p.render(),this.attachChart()},t.prototype.attachChart=function(){var t=this,e=t.chart,n=t.height,r=t.padding,o=t.value,i=t.min,a=t.max,l=t.plusColor,u=t.minusColor,p=t.barSize;e&&(e.scale({value:{max:a,min:i}}),e.height=n,e.padding=r,e.geometries[0].color("value",(function(t){return t>0?l:u})).size(p),e.changeData([{value:o}]))},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.chart&&this.ngZone.runOutsideAngular((function(){return t.chart.destroy()}))},t.decorators=[{type:e.Component,args:[{selector:"g2-single-bar",exportAs:"g2SingleBar",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}],plusColor:[{type:e.Input}],minusColor:[{type:e.Input}],height:[{type:e.Input}],barSize:[{type:e.Input}],min:[{type:e.Input}],max:[{type:e.Input}],value:[{type:e.Input}],line:[{type:e.Input}],format:[{type:e.Input}],padding:[{type:e.Input}],textStyle:[{type:e.Input}]},a([r.InputNumber(),l("design:type",Object)],t.prototype,"delay",void 0),a([r.InputNumber(),l("design:type",Object)],t.prototype,"height",void 0),a([r.InputNumber(),l("design:type",Object)],t.prototype,"barSize",void 0),a([r.InputNumber(),l("design:type",Object)],t.prototype,"min",void 0),a([r.InputNumber(),l("design:type",Object)],t.prototype,"max",void 0),a([r.InputNumber(),l("design:type",Object)],t.prototype,"value",void 0),a([r.InputBoolean(),l("design:type",Object)],t.prototype,"line",void 0),t}();var s=[c],h=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[o.CommonModule,r.LxlibUtilModule],declarations:p(s),exports:p(s)}]}],t}();t.G2SingleBarComponent=c,t.G2SingleBarModule=h,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=single-bar.umd.min.js.map