UNPKG

gantt-chart-angular

Version:

This library is used to generate gantt chart in angular application

102 lines (95 loc) 3.8 kB
import { __decorate } from 'tslib'; import { ɵɵdefineInjectable, Injectable, EventEmitter, ViewChild, Input, Output, Component, NgModule } from '@angular/core'; var GanttChartAngularService = /** @class */ (function () { function GanttChartAngularService() { } GanttChartAngularService.ɵprov = ɵɵdefineInjectable({ factory: function GanttChartAngularService_Factory() { return new GanttChartAngularService(); }, token: GanttChartAngularService, providedIn: "root" }); GanttChartAngularService = __decorate([ Injectable({ providedIn: 'root' }) ], GanttChartAngularService); return GanttChartAngularService; }()); var GanttChartAngularComponent = /** @class */ (function () { function GanttChartAngularComponent() { this.config = {}; this.onClick = new EventEmitter(); } GanttChartAngularComponent.prototype.ngOnInit = function () { var _this = this; setTimeout(function () { _this.generateChart(); }, 1000); }; /** * generate chart */ GanttChartAngularComponent.prototype.generateChart = function () { var _this = this; google.charts.load('current', { 'packages': ['gantt'] }); google.charts.setOnLoadCallback(function () { var data = new google.visualization.DataTable(); if (_this.config && _this.config.columns && _this.config.columns.length) { _this.config.columns.forEach(function (col) { data.addColumn(col.type, col.name); }); } var temp = []; if (_this.config && _this.config.data && _this.config.data.length) { _this.config.data.forEach(function (rowData) { var rowsData = []; _this.config.columns.forEach(function (col) { rowsData.push(rowData[col.field]); }); temp.push(rowsData); }); data.addRows(temp); } var options = _this.config.options; var chart = new google.visualization.Gantt(_this.chartContainer.nativeElement); chart.draw(data, options); google.visualization.events.addListener(chart, 'select', function () { var selection = chart.getSelection(); _this.onClick.emit({ selectedRow: selection[0] }); }); }); }; __decorate([ ViewChild("chartContainer") ], GanttChartAngularComponent.prototype, "chartContainer", void 0); __decorate([ Input() ], GanttChartAngularComponent.prototype, "config", void 0); __decorate([ Output() ], GanttChartAngularComponent.prototype, "onClick", void 0); GanttChartAngularComponent = __decorate([ Component({ selector: 'gantt-chart-angular', template: "<div #chartContainer></div>\r\n", styles: [""] }) ], GanttChartAngularComponent); return GanttChartAngularComponent; }()); var GanttChartAngularModule = /** @class */ (function () { function GanttChartAngularModule() { } GanttChartAngularModule = __decorate([ NgModule({ declarations: [GanttChartAngularComponent], imports: [], exports: [GanttChartAngularComponent] }) ], GanttChartAngularModule); return GanttChartAngularModule; }()); /* * Public API Surface of gantt-chart-angular */ /** * Generated bundle index. Do not edit. */ export { GanttChartAngularComponent, GanttChartAngularModule, GanttChartAngularService }; //# sourceMappingURL=gantt-chart-angular.js.map