angular2-echarts
Version:
Angular directive for echarts v3.
1 lines • 6.05 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("@angular/core")):"function"==typeof define&&define.amd?define(["@angular/core"],e):"object"==typeof exports?exports["angular2-echarts.umd.min"]=e(require("@angular/core")):t["angular2-echarts.umd.min"]=e(t["@angular/core"])}(this,function(t){return function(t){function e(n){if(i[n])return i[n].exports;var o=i[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var i={};return e.m=t,e.c=i,e.i=function(t){return t},e.d=function(t,i,n){e.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:n})},e.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(i,"a",i),i},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="/",e(e.s=2)}([function(t,e,i){"use strict";var n=i(1);i.n(n);i.d(e,"a",function(){return s});var o=this&&this.__decorate||function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s},r=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},s=function(){function t(t,e){this.el=t,this.renderer=e,this.theme="",this.chartInit=new n.EventEmitter,this.chartClick=new n.EventEmitter,this.chartDblClick=new n.EventEmitter,this.chartMouseDown=new n.EventEmitter,this.chartMouseUp=new n.EventEmitter,this.chartMouseOver=new n.EventEmitter,this.chartMouseOut=new n.EventEmitter,this.chartGlobalOut=new n.EventEmitter,this.chartDataZoom=new n.EventEmitter,this.myChart=null,this.currentWindowWidth=null}return t.prototype.createChart=function(){return this.theme=this.theme||"",this.currentWindowWidth=window.innerWidth,this.theme?echarts.init(this.el.nativeElement,this.theme):echarts.init(this.el.nativeElement)},t.prototype.updateChart=function(){this.myChart.setOption(this.options),this.myChart.resize()},t.prototype.onWindowResize=function(t){t.target.innerWidth!==this.currentWindowWidth&&(this.currentWindowWidth=t.target.innerWidth,this.myChart&&this.myChart.resize())},t.prototype.ngOnChanges=function(t){t.dataset&&this.onDatasetChange(this.dataset),t.options&&this.onOptionsChange(this.options),t.loading&&this.onLoadingChange(this.loading)},t.prototype.ngOnDestroy=function(){this.myChart&&(this.myChart.dispose(),this.myChart=null)},t.prototype.onOptionsChange=function(t){t&&(this.myChart||(this.myChart=this.createChart(),this.chartInit.emit(this.myChart),this.registerEvents(this.myChart)),this.hasData()?this.updateChart():this.dataset&&this.dataset.length&&(this.mergeDataset(this.dataset),this.updateChart()))},t.prototype.onDatasetChange=function(t){this.myChart&&this.options&&(this.options.series||(this.options.series=[]),this.mergeDataset(t),this.updateChart())},t.prototype.onLoadingChange=function(t){this.myChart&&(t?this.myChart.showLoading():this.myChart.hideLoading())},t.prototype.mergeDataset=function(t){for(var e=0,i=t.length;e<i;e++)this.options.series[e]?this.options.series[e].data=t[e]:this.options.series[e]={data:t[e]}},t.prototype.hasData=function(){if(!this.options.series||!this.options.series.length)return!1;for(var t=0,e=this.options.series;t<e.length;t++){var i=e[t];if(i.data&&i.data.length>0)return!0}return!1},t.prototype.registerEvents=function(t){var e=this;t&&(t.on("click",function(t){e.chartClick.emit(t)}),t.on("dblClick",function(t){e.chartDblClick.emit(t)}),t.on("mousedown",function(t){e.chartMouseDown.emit(t)}),t.on("mouseup",function(t){e.chartMouseUp.emit(t)}),t.on("mouseover",function(t){e.chartMouseOver.emit(t)}),t.on("mouseout",function(t){e.chartMouseOut.emit(t)}),t.on("globalout",function(t){e.chartGlobalOut.emit(t)}),t.on("dataZoom",function(t){e.chartDataZoom.emit(t)}))},t}();o([i.i(n.Input)(),r("design:type",Object)],s.prototype,"options",void 0),o([i.i(n.Input)(),r("design:type",Array)],s.prototype,"dataset",void 0),o([i.i(n.Input)(),r("design:type",String)],s.prototype,"theme",void 0),o([i.i(n.Input)(),r("design:type",Boolean)],s.prototype,"loading",void 0),o([i.i(n.Output)(),r("design:type",n.EventEmitter)],s.prototype,"chartInit",void 0),o([i.i(n.Output)(),r("design:type",n.EventEmitter)],s.prototype,"chartClick",void 0),o([i.i(n.Output)(),r("design:type",n.EventEmitter)],s.prototype,"chartDblClick",void 0),o([i.i(n.Output)(),r("design:type",n.EventEmitter)],s.prototype,"chartMouseDown",void 0),o([i.i(n.Output)(),r("design:type",n.EventEmitter)],s.prototype,"chartMouseUp",void 0),o([i.i(n.Output)(),r("design:type",n.EventEmitter)],s.prototype,"chartMouseOver",void 0),o([i.i(n.Output)(),r("design:type",n.EventEmitter)],s.prototype,"chartMouseOut",void 0),o([i.i(n.Output)(),r("design:type",n.EventEmitter)],s.prototype,"chartGlobalOut",void 0),o([i.i(n.Output)(),r("design:type",n.EventEmitter)],s.prototype,"chartDataZoom",void 0),o([i.i(n.HostListener)("window:resize",["$event"]),r("design:type",Function),r("design:paramtypes",[Object]),r("design:returntype",void 0)],s.prototype,"onWindowResize",null),s=o([i.i(n.Directive)({selector:"[echarts]"}),r("design:paramtypes",[n.ElementRef,n.Renderer])],s)},function(e,i){e.exports=t},function(t,e,i){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var n=i(1),o=(i.n(n),i(0));i.d(e,"AngularEchartsDirective",function(){return o.a}),i.d(e,"AngularEchartsModule",function(){return s});var r=this&&this.__decorate||function(t,e,i,n){var o,r=arguments.length,s=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(s=(r<3?o(s):r>3?o(e,i,s):o(e,i))||s);return r>3&&s&&Object.defineProperty(e,i,s),s},s=function(){function t(){}return t}();s=r([i.i(n.NgModule)({declarations:[o.a],exports:[o.a]})],s)}])});