Not showing tasks bar on gantt chart with resouce view

Hi, I'm making a gantt chart with resources views, based on resource view sample, but is not showing the tasks bar.

https://ej2.syncfusion.com/angular/documentation/gantt/resource-view

Image_1708_1709780596921

In console, I have this error:

3core.mjs:11860 ERROR TypeError: Cannot set properties of undefined (setting 'isResourceTaskDeleted')

    at ChartRows2.createTaskbarTemplate (chart-rows.js:1353:48)

    at ChartRows2.refreshGanttRows (chart-rows.js:1294:14)

    at ChartRows2.refreshChartByTimeline (chart-rows.js:66:14)

    at Timeline2.updateChartByNewTimeline (timeline.js:98:37)

    at Gantt2.updateProjectDates (gantt.js:2403:33)

    at GanttChart2.renderChartElements (gantt-chart.js:87:25)

    at Observer2.notify (observer.js:101:29)

    at Component2.notify (component.js:306:32)

    at Gantt2.treeDataBound (gantt.js:1343:14)

    at GanttTreeGrid2.dataBound (tree-grid.js:237:21)

handleError @ core.mjs:11860



My code:

Html content:


<ejs-gantt id="ganttDefault"
height="100%"
[dataSource]="dados"
[resources]="resources"
[resourceFields]="resourceFields"
[taskFields]="taskSettings"
[timelineSettings]="timelineSettings"
[columns]="columns"
[treeColumnIndex]="1"
[projectStartDate]="projectStartDate"
[projectEndDate]="projectEndDate"
viewType="ResourceView"></ejs-gantt>

ts component:
import { Component, ViewEncapsulation, OnInit } from '@angular/core';
import {
  ExcelExportService,
  GanttModule,
  PdfExportService,
} from '@syncfusion/ej2-angular-gantt';
import { RouterOutlet } from '@angular/router';
import { DatePipe } from '@angular/common';
import { SupabaseServiceService } from '../../services/supabase-service.service';
import { HttpClient } from '@angular/common/http';
import { Atividades } from '../../atividades';

@Component({
  selector: 'app-gantt-recursos',
  standalone: true,
  imports: [GanttModule, RouterOutlet],
  templateUrl: './gantt-recursos.component.html',
  styleUrl: './gantt-recursos.component.css',
  providers: [ExcelExportService, PdfExportService, DatePipe],
  encapsulation: ViewEncapsulation.None,
})
export class GanttRecursosComponent implements OnInit {
  // Data for Gantt
  public data?: object[];
  public resources: object[] = [];
  public taskSettings?: object;
  public labelSettings?: object;
  public projectStartDate?: Date;
  public projectEndDate?: Date;

  resourceFields: { id: string; name: string; unit: string; group: string } = {
    id: 'resourceId',
    name: 'resourceName',
    unit: 'Unit',
    group: 'resourceGroup',
  };

  editSettings: {
    allowAdding: boolean;
    allowEditing: boolean;
    allowDeleting: boolean;
    allowTaskbarEditing: boolean;
    showDeleteConfirmDialog: boolean;
  } = {
    allowAdding: true,
    allowEditing: true,
    allowDeleting: true,
    allowTaskbarEditing: true,
    showDeleteConfirmDialog: true,
  };

  columns: {
    field: string;
    visible?: boolean;
    headerText?: string;
    width?: number;
  }[] = [
    { field: 'id', visible: false },
    { field: 'titulo', headerText: 'Name', width: 250 },
    { field: 'avanco' },
    { field: 'resourceGroup', headerText: 'Group' },
    { field: 'dtinicio_previsto' },
    { field: 'dttermino_previsto' },
  ];
  public timelineSettings?: object = {
    timelineViewMode: 'Year',
    timelineUnitSize: 80,
  };
  toolbar: string[] | undefined;
  splitterSettings: { columnIndex: number } | undefined;

  constructor(
    private http: HttpClient,
    public supabaseService: SupabaseServiceService
  ) {}

  public ngOnInit(): void {
    this.resources = [];
    this.taskSettings = {
      id: 'id',
      name: 'titulo',
      startDate: 'dtinicio_previsto',
      endDate: 'dttermino_previsto',
      progress: 'avanco',
      resourceInfo: 'assignee',
      child: 'subtasks',
    };

    this.toolbar = [
      'Add',
      'Edit',
      'Update',
      'Delete',
      'Cancel',
      'ExpandAll',
      'CollapseAll',
    ];
    this.splitterSettings = {
      columnIndex: 3,
    };
    this.projectStartDate = new Date('01/01/2023');
    this.projectEndDate = new Date('12/31/2024');
    this.carregarDados('');
  }

  // Data for Gantt
  public dataTemp: any;
  public dados?: Atividades[];
  //carrega dados provenientes do supabase view: vw_atividadesl
  private carregarDados(mostrar: string) {
    var filtro = '';
    if (mostrar == 'projetos') filtro = '&inc_plano_projetos=eq.true';
    else if (mostrar == 'privado') filtro = '&privado=eq.true';
    else if (mostrar == 'gestao') filtro = '&inc_plano_gestao=eq.true';
    this.http.get(myurl).subscribe((response) => {
      this.dataTemp = response;
      this.dados = [];
      this.resources = [];
      this.dataTemp.forEach((value: Atividades) => {
        //remove caracteres especiais dos titulos, pois estava dando erro ao exportar para PDF
        value.titulo = value.titulo.replace(
          /[^a-zA-Z [{}\],.<>?ªº_+-=§!@#$%&*()çÇãÃõÕáÁéÉíÍóÓúÚâÂêÊôÔàÀ]/g,
          ''
        );
        value.origem_titulo = value.origem_titulo.replace(
          /[^a-zA-Z [{}\],.<>?ªº_+-=§!@#$%&*()çÇãÃõÕáÁéÉíÍóÓúÚâÂêÊôÔàÀ]/g,
          ''
        );

        //add resource to list
        var resource = this.resources!.find(
          (o: any) => o.resourceId === value.atribuidopara
        );

        if (resource == null) {
          this.resources.push({
            resourceId: value.atribuidopara,
            resourceName: value.atribuidopara_nome,
          });
        }
        value.assignee = [
          { resourceId: value.atribuidopara, resourceUnit: 100 },
        ];

        this.dados!.push(value);
      });
    });
  }
}


3 Replies

SJ Sridharan Jayabalan Syncfusion Team March 11, 2024 03:30 AM UTC

Ricardo,

 

For your query, we have made sample by your provided code snippet but there is incompatibility with external folders. So we have made sample with local data source and remaining all we used your code snippets. 

 

We are able to replicate your issue, with wrong dataSource mapping ([dataSource]="invalid variable"]) in the html file. So kindly ensure at your application whether this issue occurred or not. 

 

If still facing same issue, share the deatils asked below to investigate further.

 

  1. Gantt Chart version?
  2. What is the Timezone are you using?
  3. Complete code details.
  4. Proper replication procedure for the issue.
  5. Is the console error occurred at initial render or after any edit action performed?
  6. If possible replicate the issue with the provided sample below and revert us back.

 

  

 

Regards,

Sridharan



MA Muhamad Arif December 16, 2024 12:49 PM UTC

 Hi Ricardo,

Have you found your problem's root cause? I also experienced this problem on my project. this happens intermittently and I cannot find what is the root cause. the Gantt chart was just only stuck on the loading bar and not showing any graph.

imageedit_3_8471498561.png



SJ Sridharan Jayabalan Syncfusion Team December 17, 2024 10:10 AM UTC

Muhamad,


Thank you for sharing the details. The console error you mentioned has been resolved in our latest version 28.1.33, and it will no longer occur, even if an incorrect variable name is used for the dataSource within the <ejs-gantt> component. We kindly recommend upgrading your Gantt chart to the latest version to address this issue.


Updated sample - 4bkkmf (forked) - StackBlitz


Please let us know if you need further assistance or have any additional queries.


Regards,

Sridharan


Loader.
Up arrow icon