- Home
- Forum
- Angular - EJ 2
- Right label of taskbar get cropped within timeline
Right label of taskbar get cropped within timeline
- Gantt have a method called updateProjectDates which is used to update the timeline dynamically by passing start date and end date of timeline.
- If we extend the timeline to the maximum width then need to find the maximum end date and it is used to update the timeline.
- By summation of taskbar left, taskbar width and label text container width. It will give the end Point of a row. Similarly, we need to sort out the maximum end point from the available tasks.
- We have prepared a custom method called “getDateByLeft()” which is give the date by end Point.
|
[app.component.html]
<button ejs-button (click)="changeTimeline()"> Update Timeline </button>
<ejs-gantt #gantt id="ganttDefault"
//……
</ejs-gantt>
[app.component.ts]
export class AppComponent {
@ViewChild('gantt', {static: true})
public ganttObj: GanttComponent;
public ngOnInit(): void {
//……
}
changeTimeline(): void {
var task = this.ganttObj.getRecordByID(12);
var taskbarLeft = task.ganttProperties.left;
var taskbarWidth = task.ganttProperties.width;
var rowElement = this.ganttObj.getRowByID(task.TaskID);
var labelElement = rowElement.querySelector('.e-right-label-container');
var totalLeft = taskbarLeft + taskbarWidth + labelElement.offsetWidth + 25; // 25 is the margin value
var newDate: Date = this.getDateByLeft(totalLeft);
this.ganttObj.updateProjectDates(this.ganttObj.timelineModule.timelineStartDate, newDate);
} |
Could you provide a method for doing the same but for the left label?
Hi John Doe,
We are currently working on your query and will share further details within two business days on October 4, 2022. Until then we appreciate your patience.
Regards,
Gopinath M
Hi John Doe,
Thanks for the patience.
We have prepared a sample to achieve your requirement. In this sample, we have modified the same with left label using a custom method getDateByRight() also we must modify the newDate and timelineEndDate value inside the updateProjectDates method. We have attached a sample and code snippets for your reference, please check the below sample and code snippets for more details.
Code snippets:
|
changeTimeline(): void { var task = this.ganttObj.getRecordByID(12); var taskbarLeft = task.ganttProperties.left; var taskbarWidth = task.ganttProperties.width; var rowElement = this.ganttObj.getRowByID(task.TaskID); var labelElement = rowElement.querySelector('.e-left-label-container'); var totalLeft = taskbarLeft + taskbarWidth + labelElement.offsetWidth + 25; //Element's margin left; var newDate: Date = this.getDateByRight(totalLeft); this.ganttObj.updateProjectDates( newDate, this.ganttObj.timelineModule.timelineEndDate ); } //… public getDateByRight(right: number): Date { let pEndDate: Date = new Date( this.ganttObj.timelineModule.timelineEndDate.toString() ); let milliSecondsPerPixel: number = (24 * 60 * 60 * 1000) / this.ganttObj.perDayWidth; pEndDate.setTime(pEndDate.getTime() - right * milliSecondsPerPixel); let tierMode: string = this.ganttObj.timelineModule.bottomTier !== 'None' ? this.ganttObj.timelineModule.topTier : this.ganttObj.timelineModule.bottomTier; //... } return pEndDate; } |
Sample: https://stackblitz.com/edit/angular-z7rsmw-b9pvb7?file=app.component.ts
Regards,
Gopinath M
- 6 Replies
- 4 Participants
-
NI Nikitha
- Jan 18, 2020 08:50 AM UTC
- Oct 5, 2022 01:33 AM UTC