ng2-gantt
Version:
Angular 2 Gantt
98 lines (84 loc) • 3.14 kB
text/typescript
import { Component, OnInit, Input, EventEmitter, ViewChild } from '@angular/core';
import { GanttService } from '../../shared/services/gantt.service';
import { Zooming } from '../../shared/interfaces';
export class GanttTimeScaleComponent implements OnInit {
timeScale: any;
dimensions: any;
zoom: any;
zoomLevel: any;
constructor(private ganttService: GanttService) { }
ngOnInit() {
this.zoom.subscribe((zoomLevel: string) => {
this.zoomLevel = zoomLevel;
});;
}
private setTimescaleStyle() {
return {
'width': this.dimensions.width + 'px'
};
}
private setTimescaleLineStyle(borderTop: string) {
return {
'height': this.ganttService.rowHeight + 'px',
'line-height': this.ganttService.rowHeight + 'px',
'position': 'relative',
'border-top': borderTop
};
}
private setTimescaleCellStyle() {
var width = this.ganttService.cellWidth;
var hoursInDay = 24;
var hourSeperatorPixels = 23; // we don't include the first
if(this.zoomLevel === Zooming[Zooming.hours]) {
width = this.ganttService.hourCellWidth * hoursInDay + hourSeperatorPixels;
}
return {
'width': width + 'px'
};
}
private isDayWeekend(date: Date): boolean {
return this.ganttService.isDayWeekend(date);
}
private getHours(): string[] {
return this.ganttService.getHours(this.timeScale.length);
}
}