Getting Started with the Kendo UI for Angular Gantt
This guide provides the information you need to start using the Kendo UI for Angular Gantt—it includes instructions about the recommended installation approach, the code for running the project, and links to additional resources.
As of version
17.0.0, Angular makes standalone component enabled by default. If you useNgModules, refer to these articles:
The standalone components in Angular streamline development by removing the need for NgModules, reducing complexity, and enhancing component reuse and modularity. This approach simplifies dependency management, making applications more maintainable and scalable.
After the completion of this guide, you will be able to achieve an end result as demonstrated in the following example.
Setting Up Your Angular Project
Before you start with the installation of any Kendo UI for Angular control, ensure that you have a running Angular project. The prerequisites to accomplish the installation of the components are always the same regardless of the Kendo UI for Angular package you want to use, and are fully described in the section on setting up your Angular project.
Installing the Component
The following command demonstrates an efficient, automated method for adding packages using the Angular CLI through the ng-add command. This approach saves time and effort by executing a series of commands in a single step, which otherwise need to be run individually. Refer to the Manual Setup for more details.
To add the Kendo UI for Angular Gantt package:
-
Run the following command:
shng add @progress/kendo-angular-ganttAs a result, the
ng-addcommand will perform the following actions:- Add the
@progress/kendo-angular-ganttpackage as a dependency to thepackage.jsonfile. - Add all required peer dependencies to the
package.jsonfile. - Register the Kendo UI Default theme in the
angular.jsonfile. - Trigger
npm installto install the theme and all peer packages that are added.
- Add the
-
Import the
KENDO_GANTTutility array in your standalone component to enable the entire feature set of the Gantt:The utility array is available starting from v16.6.0. If you use an older version of the package, please follow the approach from the Using Kendo Angular Components with NgModules article.
tsimport { Component } from '@angular/core'; import { KENDO_GANTT } from '@progress/kendo-angular-gantt'; @Component({ standalone: true, selector: 'my-app', imports: [KENDO_GANTT] })
Using the Component
-
After successfully installing the Gantt package and importing its module, add the following code in the
app.component.htmlfile:html<kendo-gantt [style.height.px]="500" [kendoGanttHierarchyBinding]="data" childrenField="subtasks" [dependencies]="dependencies" > <kendo-gantt-column field="title" title="Task" [width]="200" [expandable]="true" ></kendo-gantt-column> <kendo-gantt-column field="start" title="Start" format="dd-MMM-yyyy" [width]="120" ></kendo-gantt-column> <kendo-gantt-column field="end" title="End" format="dd-MMM-yyyy" [width]="120" ></kendo-gantt-column> <kendo-gantt-timeline-day-view></kendo-gantt-timeline-day-view> <kendo-gantt-timeline-week-view></kendo-gantt-timeline-week-view> <kendo-gantt-timeline-month-view></kendo-gantt-timeline-month-view> </kendo-gantt> -
Bind the
kendoGanttHierarchyBindingdirective to an array of data items representing the Gantt tasks by adding the following code in theapp.component.tsfile:tspublic data: Task[] = [{ id: 7, title: 'Validation and R&D', start: new Date('2014-06-02T00:00:00.000Z'), end: new Date('2014-06-19T00:00:00.000Z'), completionRatio: 0.45708333333333334, subtasks: [ { id: 18, title: 'Project Kickoff', start: new Date('2014-06-02T00:00:00.000Z'), end: new Date('2014-06-02T00:00:00.000Z'), completionRatio: 0.23 }, { id: 11, title: 'Research', start: new Date('2014-06-02T00:00:00.000Z'), end: new Date('2014-06-07T00:00:00.000Z'), completionRatio: 0.5766666666666667, subtasks: [ { id: 19, title: 'Validation', start: new Date('2014-06-02T00:00:00.000Z'), end: new Date('2014-06-04T00:00:00.000Z'), completionRatio: 0.25 }, { id: 39, title: 'Specification', start: new Date('2014-06-04T00:00:00.000Z'), end: new Date('2014-06-07T00:00:00.000Z'), completionRatio: 0.66 }] }, { id: 13, title: 'Implementation', start: new Date('2014-06-08T00:00:00.000Z'), end: new Date('2014-06-19T00:00:00.000Z'), completionRatio: 0.77, subtasks: [ { id: 24, title: 'Prototype', start: new Date('2014-06-08T00:00:00.000Z'), end: new Date('2014-06-14T00:00:00.000Z'), completionRatio: 0.77 }, { id: 29, title: 'UI and Interaction', start: new Date('2014-06-14T00:00:00.000Z'), end: new Date('2014-06-19T00:00:00.000Z'), completionRatio: 0.6 }] }, { id: 17, title: 'Release', start: new Date('2014-06-19T00:00:00.000Z'), end: new Date('2014-06-19T00:00:00.000Z'), completionRatio: 0 }] }]; -
Bind the
dependenciesinput to an array of task dependencies by adding the following code in theapp.component.tsfile:tspublic dependencies: GanttDependency[] = [ { id: 528, fromId: 18, toId: 19, type: DependencyType.FS }, { id: 529, fromId: 19, toId: 39, type: DependencyType.FS }, { id: 535, fromId: 24, toId: 29, type: DependencyType.FS }, { id: 551, fromId: 13, toId: 29, type: DependencyType.FF }, { id: 777, fromId: 7, toId: 11, type: DependencyType.SF }, { id: 556, fromId: 39, toId: 24, type: DependencyType.FS }, { id: 546, fromId: 29, toId: 17, type: DependencyType.FS }, ]; -
Build and serve the application by running the following command in the root folder.
shng serve -
Point your browser to http://localhost:4200 to see the Kendo UI for Angular Gantt component on the page.
Activating Your License Key
As of December 2020, using any of the UI components from the Kendo UI for Angular library requires either a commercial license key or an active trial license key. If your application does not contain a Kendo UI license file, activate your license key.
Next Steps
- Gantt Dependencies & Standalone Utilities
- Binding the Gantt to data
- Configuring the Gantt columns
- Implementing sorting and filtering in the Gantt
- Setting the tasks and task dependencies of the Gantt
- Managing the Gantt views, panes, and toolbars
- Explore the editing options the Gantt provides
- Enable the keyboard navigation
- API Reference of the Gantt