UNPKG

@covalent/echarts

Version:
2 lines 12.7 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/common"),require("rxjs/operators"),require("echarts/lib/echarts"),require("rxjs"),require("zrender/lib/svg/svg"),require("@angular/core")):"function"==typeof define&&define.amd?define("@covalent/echarts/base",["exports","@angular/common","rxjs/operators","echarts/lib/echarts","rxjs","zrender/lib/svg/svg","@angular/core"],e):e((t.covalent=t.covalent||{},t.covalent.echarts=t.covalent.echarts||{},t.covalent.echarts.base={}),t.ng.common,t.rxjs.operators,t.echarts,t.rxjs,null,t.ng.core)}(this,function(t,e,n,i,o,s,a){"use strict";var r=function(){function t(){this._options={},this._optionsSubject=new o.BehaviorSubject(this._options)}return t.prototype.setOption=function(t,e){var n={};n[t]=e,Object.assign(this._options,n),this._optionsSubject.next(this._options)},t.prototype.setArrayOption=function(t,e){var n=this.getOption(t);if(n){var i=n.indexOf(e);-1<i?n[i]=e:n.push(e)}else n=[e];this.setOption(t,n)},t.prototype.removeArrayOption=function(t,e){var n=this.getOption(t);if(n){var i=n.indexOf(e);-1<i?n[i]=null:n=[]}this.setOption(t,n)},t.prototype.getOption=function(t){return this._options[t]},t.prototype.clearOption=function(t){this.setOption(t,null)},t.prototype.listen=function(){return this._optionsSubject.asObservable()},t.decorators=[{type:a.Injectable}],t}();function p(t){return t||new r}var c={provide:r,deps:[[new a.Optional,new a.SkipSelf,r]],useFactory:p},h=function(t,e){return(h=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)};function u(t,e){function n(){this.constructor=t}h(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function O(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}}function l(t){for(var e,n,i,o,s,a,r=[],p=1;p<arguments.length;p++)r[p-1]=arguments[p];var c=new Set;try{for(var h=O(r),u=h.next();!u.done;u=h.next()){var l=u.value;try{for(var g=O(Object.keys(l)),y=g.next();!y.done;y=g.next()){var m=y.value;c.add(m);var d=l[m];d!==undefined&&null!==d?t[m]=d:null===d&&delete t[m]}}catch(v){i={error:v}}finally{try{y&&!y.done&&(o=g["return"])&&o.call(g)}finally{if(i)throw i.error}}}}catch(b){e={error:b}}finally{try{u&&!u.done&&(n=h["return"])&&n.call(h)}finally{if(e)throw e.error}}try{for(var f=O(Object.keys(t)),_=f.next();!_.done;_=f.next()){m=_.value;c.has(m)||delete t[m]}}catch(x){s={error:x}}finally{try{_&&!_.done&&(a=f["return"])&&a.call(f)}finally{if(s)throw s.error}}return t}var g=function(){function t(t,e,n){this._changeDetectorRef=t,this._elementRef=e,this._optionsService=n,this._destroy=new o.Subject,this._widthSubject=new o.Subject,this._heightSubject=new o.Subject,this._state={},this._options={},this.config={},this.renderer="canvas",this.chartClick=new a.EventEmitter,this.chartDblclick=new a.EventEmitter,this.chartContextmenu=new a.EventEmitter,this.magicTypeChanged=new a.EventEmitter,this.dataViewChanged=new a.EventEmitter,this.datazoom=new a.EventEmitter,this.restore=new a.EventEmitter}return Object.defineProperty(t.prototype,"instance",{get:function(){return this._instance},enumerable:!0,configurable:!0}),t.prototype.ngAfterViewInit=function(){this._initializeChart()},t.prototype.ngOnChanges=function(t){this._instance&&(t.renderer||t.themeName||t.group?(this._disposeChart(),this._initializeChart()):this.render())},t.prototype.ngOnDestroy=function(){this._disposeChart(),this._destroy.unsubscribe()},t.prototype.render=function(){this._instance&&(this._instance.setOption(l(this._state,{grid:{show:!0,left:"20",right:"20",bottom:this.config.toolbox&&"number"==typeof this.config.toolbox.bottom||this._options.toolbox&&"number"==typeof this._options.toolbox.bottom?"40":"10",top:this.config.toolbox&&"number"==typeof this.config.toolbox.top||this._options.toolbox&&"number"==typeof this._options.toolbox.top?"40":"10",containLabel:!0,borderColor:"#FCFCFC"}},this._options,this.config?this.config:{}),!0),this._changeDetectorRef.markForCheck())},t.prototype._initializeChart=function(){var e=this;this._instance=i.init(this._elementRef.nativeElement,this.themeName,{renderer:this.renderer}),o.fromEvent(this._instance,"click").pipe(n.takeUntil(this._destroy)).subscribe(function(t){e.chartClick.next(t)}),o.fromEvent(this._instance,"dblclick").pipe(n.takeUntil(this._destroy)).subscribe(function(t){e.chartDblclick.next(t)}),o.fromEvent(this._instance,"contextmenu").pipe(n.takeUntil(this._destroy)).subscribe(function(t){e.chartContextmenu.next(t)}),o.fromEvent(this._instance,"magictypechanged").pipe(n.takeUntil(this._destroy)).subscribe(function(t){e.magicTypeChanged.next(t)}),o.fromEvent(this._instance,"dataviewchanged").pipe(n.takeUntil(this._destroy)).subscribe(function(t){e.dataViewChanged.next(t)}),o.fromEvent(this._instance,"datazoom").pipe(n.takeUntil(this._destroy)).subscribe(function(t){e.datazoom.next(t)}),o.fromEvent(this._instance,"restore").pipe(n.takeUntil(this._destroy)).subscribe(function(t){e.restore.next(t)}),this.group&&(this._instance.group=this.group,i.connect(this.group),this._changeDetectorRef.markForCheck()),o.merge(o.fromEvent(window,"resize").pipe(n.debounceTime(100)),this._widthSubject.asObservable().pipe(n.distinctUntilChanged()),this._heightSubject.asObservable().pipe(n.distinctUntilChanged())).pipe(n.takeUntil(this._destroy),n.debounceTime(100)).subscribe(function(){e._instance&&(e._instance.resize(),e._changeDetectorRef.markForCheck())}),this._optionsService.listen().pipe(n.tap(function(t){l(e._options,t)}),n.debounceTime(0),n.takeUntil(this._destroy)).subscribe(function(){e.render()}),o.timer(500,250).pipe(n.takeUntil(this._destroy)).subscribe(function(){e._elementRef&&e._elementRef.nativeElement&&(e._widthSubject.next(e._elementRef.nativeElement.getBoundingClientRect().width),e._heightSubject.next(e._elementRef.nativeElement.getBoundingClientRect().height))})},t.prototype._disposeChart=function(){this._instance&&(this._instance.clear(),i.dispose(this._instance)),this._destroy.next(!0)},t.decorators=[{type:a.Component,args:[{selector:"td-chart",template:"",changeDetection:a.ChangeDetectionStrategy.OnPush,providers:[c],styles:[":host{display:block;width:100%}"]}]}],t.ctorParameters=function(){return[{type:a.ChangeDetectorRef},{type:a.ElementRef},{type:r}]},t.propDecorators={config:[{type:a.Input,args:["config"]}],group:[{type:a.Input,args:["group"]}],themeName:[{type:a.Input,args:["themeName"]}],renderer:[{type:a.Input,args:["renderer"]}],chartClick:[{type:a.Output,args:["chartClick"]}],chartDblclick:[{type:a.Output,args:["chartDblclick"]}],chartContextmenu:[{type:a.Output,args:["chartContextmenu"]}],magicTypeChanged:[{type:a.Output,args:["magicTypeChanged"]}],dataViewChanged:[{type:a.Output,args:["dataViewChanged"]}],datazoom:[{type:a.Output,args:["datazoom"]}],restore:[{type:a.Output,args:["restore"]}]},t}(),y=function(){function t(t,e){this._axisOption=t,this._optionsService=e,this._state={axisLine:{lineStyle:{color:"#ABABAB"}},splitLine:{lineStyle:{color:"#ABABAB"}}},this.config={},this.show=!0}return t.prototype.ngOnInit=function(){this._setOptions()},t.prototype.ngOnChanges=function(){this._setOptions()},t.prototype.ngOnDestroy=function(){this._removeOption()},t.prototype._setOptions=function(){var t=l(this._state,{id:this.id,show:this.show,gridIndex:this.gridIndex,position:this.position,offset:this.offset,type:this.type,name:this.name,nameLocation:this.nameLocation,nameTextStyle:this.nameTextStyle,nameGap:this.nameGap,nameRotate:this.nameRotate,inverse:this.inverse,boundaryGap:this.boundaryGap,min:this.min,max:this.max,scale:this.scale,minInterval:this.minInterval,interval:this.interval,logBase:this.logBase,silent:this.silent,triggerEvent:this.triggerEvent,axisLine:this.axisLine,axisTick:this.axisTick,axisLabel:this.axisLabel,splitLine:this.splitLine,splitArea:this.splitArea,data:this.data,axisPointer:this.axisPointer,zlevel:this.zlevel,z:this.z},this.config?this.config:{});this._optionsService.setArrayOption(this._axisOption,t)},t.prototype._removeOption=function(){this._optionsService.clearOption(this._axisOption)},t.propDecorators={config:[{type:a.Input,args:["config"]}],id:[{type:a.Input,args:["id"]}],show:[{type:a.Input,args:["show"]}],gridIndex:[{type:a.Input,args:["gridIndex"]}],offset:[{type:a.Input,args:["offset"]}],type:[{type:a.Input,args:["type"]}],name:[{type:a.Input,args:["name"]}],nameLocation:[{type:a.Input,args:["nameLocation"]}],nameTextStyle:[{type:a.Input,args:["nameTextStyle"]}],nameGap:[{type:a.Input,args:["nameGap"]}],nameRotate:[{type:a.Input,args:["nameRotate"]}],inverse:[{type:a.Input,args:["inverse"]}],boundaryGap:[{type:a.Input,args:["boundaryGap"]}],min:[{type:a.Input,args:["min"]}],max:[{type:a.Input,args:["max"]}],scale:[{type:a.Input,args:["scale"]}],minInterval:[{type:a.Input,args:["minInterval"]}],interval:[{type:a.Input,args:["interval"]}],logBase:[{type:a.Input,args:["logBase"]}],silent:[{type:a.Input,args:["silent"]}],triggerEvent:[{type:a.Input,args:["triggerEvent"]}],axisLine:[{type:a.Input,args:["axisLine"]}],axisTick:[{type:a.Input,args:["axisTick"]}],axisLabel:[{type:a.Input,args:["axisLabel"]}],splitLine:[{type:a.Input,args:["splitLine"]}],splitArea:[{type:a.Input,args:["splitArea"]}],data:[{type:a.Input,args:["data"]}],axisPointer:[{type:a.Input,args:["axisPointer"]}],zlevel:[{type:a.Input,args:["zlevel"]}],z:[{type:a.Input,args:["z"]}]},t}(),m=function(e){function t(t){return e.call(this,"xAxis",t)||this}return u(t,e),t.decorators=[{type:a.Component,args:[{selector:"td-chart-x-axis",template:"",changeDetection:a.ChangeDetectionStrategy.OnPush}]}],t.ctorParameters=function(){return[{type:r}]},t.propDecorators={position:[{type:a.Input,args:["position"]}]},t}(y),d=function(e){function t(t){return e.call(this,"yAxis",t)||this}return u(t,e),t.decorators=[{type:a.Component,args:[{selector:"td-chart-y-axis",template:"",changeDetection:a.ChangeDetectionStrategy.OnPush}]}],t.ctorParameters=function(){return[{type:r}]},t.propDecorators={position:[{type:a.Input,args:["position"]}]},t}(y),f=[g,m,d],_=function(){function t(){}return t.decorators=[{type:a.NgModule,args:[{imports:[e.CommonModule],declarations:[f],exports:[f]}]}],t}(),v=function(){function t(t,e){this.optionsService=e,this._state={},this._options={},this.config={},this._type=t}return Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),t.prototype.ngOnInit=function(){this._setOptions()},t.prototype.ngOnChanges=function(){this._setOptions()},t.prototype.ngOnDestroy=function(){this._removeOption()},t.prototype.setStateOption=function(t,e){this._options[t]=e,this._setOptions()},t.prototype.removeStateOption=function(t){this._options[t]=null,this._setOptions()},t.prototype._setOptions=function(){var t=l(this._state,{id:this.id,type:this.type,name:this.name,color:this.color,data:this.data,animation:this.animation,animationThreshold:this.animationThreshold,animationDuration:this.animationDuration,animationEasing:this.animationEasing,animationDelay:this.animationDelay,animationDurationUpdate:this.animationDurationUpdate,animationEasingUpdate:this.animationEasingUpdate,animationDelayUpdate:this.animationDelayUpdate,tooltip:this.tooltip},this.getConfig(),this._options,this.config?this.config:{});this.optionsService.setArrayOption("series",t)},t.prototype._removeOption=function(){this.optionsService.removeArrayOption("series",this._state)},t.propDecorators={config:[{type:a.Input,args:["config"]}],id:[{type:a.Input,args:["id"]}],name:[{type:a.Input,args:["name"]}],color:[{type:a.Input,args:["color"]}],data:[{type:a.Input,args:["data"]}],animation:[{type:a.Input,args:["animation"]}],animationThreshold:[{type:a.Input,args:["animationThreshold"]}],animationDuration:[{type:a.Input,args:["animationDuration"]}],animationEasing:[{type:a.Input,args:["animationEasing"]}],animationDelay:[{type:a.Input,args:["animationDelay"]}],animationDurationUpdate:[{type:a.Input,args:["animationDurationUpdate"]}],animationEasingUpdate:[{type:a.Input,args:["animationEasingUpdate"]}],animationDelayUpdate:[{type:a.Input,args:["animationDelayUpdate"]}],tooltip:[{type:a.Input,args:["tooltip"]}]},t}();t.TdChartComponent=g,t.TdChartAxisComponent=y,t.TdChartYAxisComponent=d,t.TdChartXAxisComponent=m,t.TdChartOptionsService=r,t.CHART_PROVIDER=c,t.BASE_MODULE_COMPONENTS=f,t.CovalentBaseEchartsModule=_,t.assignDefined=l,t.TdSeriesComponent=v,t.ɵa=p,Object.defineProperty(t,"__esModule",{value:!0})}); //# sourceMappingURL=covalent-echarts-base.umd.min.js.map