@dlhsoft/ganttcharthyperlibrary
Version:
Gantt Chart library for JavaScript and TypeScript with Angular, React, and Vue extensions
64 lines (61 loc) • 2.73 kB
text/typescript
import { Component, OnInit, ElementRef, Input } from '@angular/core';
import PertChartItem = DlhSoft.Controls.Pert.PertChartView.Item;
import PertChartSettings = DlhSoft.Controls.Pert.PertChartView.Settings;
import NetworkDiagramItem = DlhSoft.Controls.Pert.NetworkDiagramView.Item;
import NetworkDiagramSettings = DlhSoft.Controls.Pert.NetworkDiagramView.Settings;
export class PertChartView implements OnInit {
rootElement: HTMLElement;
style: string = "";
items: PertChartItem[] = [];
settings: PertChartSettings = {};
license: string;
change: (item: PertChartItem, propertyName: string, isDirect: boolean, isFinal: boolean) => void;
constructor(elementRef: ElementRef) {
this.rootElement = <HTMLElement>elementRef.nativeElement;
}
ngOnInit() {
var element = <HTMLElement>this.rootElement.firstChild;
element.setAttribute('style', this.style);
var changeHandler = this.settings.itemPropertyChangeHandler;
DlhSoft.Controls.Pert.PertChartView.initialize(element, this.items, this.settings, this.license);
if (this.change) {
this.settings.itemPropertyChangeHandler = (item, propertyName, isDirect, isFinal) => {
if (changeHandler)
changeHandler(item, propertyName, isDirect, isFinal);
this.change(item, propertyName, isDirect, isFinal);
}
}
}
}
export class NetworkDiagramView implements OnInit {
rootElement: HTMLElement;
style: string = "";
items: NetworkDiagramItem[] = [];
settings: NetworkDiagramSettings = {};
license: string;
change: (item: NetworkDiagramItem, propertyName: string, isDirect: boolean, isFinal: boolean) => void;
constructor(elementRef: ElementRef) {
this.rootElement = <HTMLElement>elementRef.nativeElement;
}
ngOnInit() {
var element = <HTMLElement>this.rootElement.firstChild;
element.setAttribute('style', this.style);
var changeHandler = this.settings.itemPropertyChangeHandler;
DlhSoft.Controls.Pert.NetworkDiagramView.initialize(element, this.items, this.settings, this.license);
if (this.change) {
this.settings.itemPropertyChangeHandler = (item, propertyName, isDirect, isFinal) => {
if (changeHandler)
changeHandler(item, propertyName, isDirect, isFinal);
this.change(item, propertyName, isDirect, isFinal);
}
}
}
}