@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.22 kB
JavaScript
!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/gauge",["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.gauge={}),t.ng.core,t.g2,t.lxlib.util,t.ng.common)}(this,(function(t,e,n,o,r){"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 i(t,e,n,o){var r,i=arguments.length,a=i<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,o);else for(var l=t.length-1;l>=0;l--)(r=t[l])&&(a=(i<3?r(a):i>3?r(e,n,a):r(e,n))||a);return i>3&&a&&Object.defineProperty(e,n,a),a}function a(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}function l(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var o,r,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(o=i.next()).done;)a.push(o.value)}catch(t){r={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}return a}function u(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(l(arguments[e]));return t}var c=function(){function t(t,e){this.el=t,this.ngZone=e,this.delay=0,this.color="#2f9cff",this.bgColor="#f0f2f5",this.padding=[10,10,30,10]}return t.prototype.install=function(){n.registerShape("point","pointer",{draw:function(t,e){var n=e.addGroup({}),o=this.parsePoint({x:0,y:0});return n.addShape("line",{attrs:{x1:o.x,y1:o.y,x2:t.x,y2:t.y,stroke:t.color,lineWidth:2.5,lineCap:"round"}}),n.addShape("circle",{attrs:{x:o.x,y:o.y,r:5.75,stroke:t.color,lineWidth:2,fill:"#fff"}}),n}});var t=this.el,e=this.height,o=this.padding,r=this.format,i=this.chart=new n.Chart({container:t.nativeElement,autoFit:!0,height:e,padding:o});i.legend(!1),i.animate(!1),i.tooltip(!1),i.coordinate("polar",{startAngle:-9/8*Math.PI,endAngle:1/8*Math.PI,radius:.75}),i.scale("value",{min:0,max:100,nice:!0,tickCount:6}),i.axis("1",!1),i.axis("value",{line:null,label:{offset:-12,formatter:r},tickLine:null,grid:null}),i.point().position("value*1").shape("pointer"),this.attachChart()},t.prototype.attachChart=function(){var t=this,e=t.chart,n=t.percent,o=t.color,r=t.bgColor,i=t.title;if(e){var a=[{name:i,value:n}],l=a[0].value;e.annotation().clear(!0),e.geometries[0].color(o),e.annotation().arc({top:!1,start:[0,.95],end:[100,.95],style:{stroke:r,lineWidth:12,lineDash:null}}),e.annotation().arc({start:[0,.95],end:[a[0].value,.95],style:{stroke:o,lineWidth:12,lineDash:null}}),e.annotation().text({position:["50%","85%"],content:i,style:{fontSize:12,fill:"rgba(0, 0, 0, 0.43)",textAlign:"center"}}),e.annotation().text({position:["50%","90%"],content:l+" %",style:{fontSize:24,fill:"rgba(0, 0, 0, 0.85)",textAlign:"center"},offsetY:15}),e.changeData(a)}},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-gauge",exportAs:"g2Gauge",template:"",host:{"[class.g2-gauge]":"true"},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}],title:[{type:e.Input}],height:[{type:e.Input}],color:[{type:e.Input}],bgColor:[{type:e.Input}],format:[{type:e.Input}],percent:[{type:e.Input}],padding:[{type:e.Input}]},i([o.InputNumber(),a("design:type",Object)],t.prototype,"delay",void 0),i([o.InputNumber(),a("design:type",Number)],t.prototype,"height",void 0),i([o.InputNumber(),a("design:type",Number)],t.prototype,"percent",void 0),t}();var p=[c],s=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[r.CommonModule,o.LxlibUtilModule],declarations:u(p),exports:u(p)}]}],t}();t.G2GaugeComponent=c,t.G2GaugeModule=s,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=gauge.umd.min.js.map