@lxlib/chart
Version:
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 9.1.1.
2 lines • 5.14 kB
JavaScript
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@antv/data-set"),require("@antv/g2"),require("@lxlib/util"),require("@angular/common"),require("ng-zorro-antd/core/outlet")):"function"==typeof define&&define.amd?define("@lxlib/chart/timeline",["exports","@angular/core","@antv/data-set","@antv/g2","@lxlib/util","@angular/common","ng-zorro-antd/core/outlet"],e):e(((t=t||self).lxlib=t.lxlib||{},t.lxlib.chart=t.lxlib.chart||{},t.lxlib.chart.timeline={}),t.ng.core,t.DataSet,t.g2,t.lxlib.util,t.ng.common,t["ng-zorro-antd/core/outlet"])}(this,(function(t,e,n,r,i,o,a){"use strict";n=n&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n;var l=function(){return(l=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)};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 p(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t}var d=function(){};var y=function(){function t(t){this.ngZone=t,this.delay=0,this.data=[],this.colorMap={y1:"#1890FF",y2:"#2FC25B"},this.mask="HH:mm",this.position="top",this.height=450,this.padding=[60,20,64,40],this.borderWidth=2,this.slider=!0}return t.prototype.ngOnInit=function(){var t=this;this.ngZone.runOutsideAngular((function(){return setTimeout((function(){return t.install()}),t.delay)}))},t.prototype.install=function(){var t=this,e=t.node,n=t.height,i=t.padding,o=t.mask,a=t.slider,u=this.chart=new r.Chart({container:e.nativeElement,autoFit:!0,height:n,padding:i});u.axis("x",{title:null}),u.axis("y1",{title:null}),u.axis("y2",!1),u.line().position("x*y1"),u.line().position("x*y2"),l(l({},[]),i)[0]=0,a&&u.option("slider",{height:26,start:.1,end:.8,trendCfg:{isArea:!1},mask:o}),this.attachChart()},t.prototype.attachChart=function(){var t=this,e=t.chart,r=t.height,i=t.padding,o=t.data,a=t.mask,l=t.titleMap,u=t.position,c=t.colorMap,s=t.borderWidth;if(e&&o&&!(o.length<=0)){e.legend({position:u,custom:!0,items:[{name:l.y1,value:l.y1,marker:{style:{fill:c.y1}}},{name:l.y1,value:l.y2,marker:{style:{fill:c.y2}}}]}),e.geometries.forEach((function(t,e){t.color(c["y"+(e+1)]).size(s)})),e.height=r,e.padding=i,o.filter((function(t){return!(t.x instanceof Number)})).forEach((function(t){t.x=+new Date(t.x)})),o.sort((function(t,e){return+t.x-+e.x}));var d=Math.max(p(o).sort((function(t,e){return e.y1-t.y1}))[0].y1,p(o).sort((function(t,e){return e.y2-t.y2}))[0].y2),y=new n({state:{start:o[0].x,end:o[o.length-1].x}}),h=y.createView("origin").source(o);h.transform({type:"filter",callback:function(t){var e=+t.x;return e>=y.state.start&&e<=y.state.end}}),e.scale({x:{type:"timeCat",mask:a,range:[0,1]},y1:{alias:l.y1,max:d,min:0},y2:{alias:l.y2,max:d,min:0}}),e.changeData(h.rows)}},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-timeline",exportAs:"g2Timeline",template:'<ng-container *nzStringTemplateOutlet="title">\n <h4>{{title}}</h4>\n</ng-container>\n<div #container></div>\n',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:!1}]}],delay:[{type:e.Input}],title:[{type:e.Input}],data:[{type:e.Input}],titleMap:[{type:e.Input}],colorMap:[{type:e.Input}],mask:[{type:e.Input}],position:[{type:e.Input}],height:[{type:e.Input}],padding:[{type:e.Input}],borderWidth:[{type:e.Input}],slider:[{type:e.Input}]},u([i.InputNumber(),c("design:type",Object)],t.prototype,"delay",void 0),u([i.InputNumber(),c("design:type",Object)],t.prototype,"height",void 0),u([i.InputNumber(),c("design:type",Object)],t.prototype,"borderWidth",void 0),u([i.InputBoolean(),c("design:type",Object)],t.prototype,"slider",void 0),t}();var h=[y],f=function(){function t(){}return t.decorators=[{type:e.NgModule,args:[{imports:[o.CommonModule,i.LxlibUtilModule,a.NzOutletModule],declarations:p(h),exports:p(h)}]}],t}();t.G2TimelineComponent=y,t.G2TimelineData=d,t.G2TimelineModule=f,Object.defineProperty(t,"__esModule",{value:!0})}));
//# sourceMappingURL=timeline.umd.min.js.map