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 available installation approaches, the required dependencies, the code for running the project, and links to additional resources.
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
You can choose to use either of the following two approaches for installing the Kendo UI for Angular package and the styles you want to apply:
Quick Setup with Angular CLI
The quick setup presents an automatic approach for adding packages with Angular CLI through the ng-add
command. It is suitable for saving time and efforts as ng-add
executes in a single step a set of otherwise individually needed commands.
To add the Kendo UI for Angular Gantt package, run the following command:
ng add @progress/kendo-angular-gantt
As a result, the ng-add
command will perform the following actions:
- Add the
@progress/kendo-angular-gantt
package as a dependency to thepackage.json
file. - Import the
GanttModule
in the current application module. - Register the Kendo UI Default theme in the
angular.json
file. - Add all required peer dependencies to the
package.json
file. - Trigger
npm install
to install the theme and all peer packages that are added.
Manual Setup
The manual setup provides greater visibility and better control over the files and references installed in your Angular application. You can install the required peer dependencies and a Kendo UI theme by running separate commands for each step and import the desired component modules in your application root or feature module.
-
Install the Gantt package together with its dependencies by running the following command:
npm install --save @progress/kendo-angular-gantt @progress/kendo-angular-treelist @progress/kendo-angular-dropdowns @progress/kendo-angular-treeview @progress/kendo-angular-inputs @progress/kendo-angular-dateinputs @progress/kendo-angular-layout @progress/kendo-angular-dialog @progress/kendo-angular-progressbar @progress/kendo-data-query @progress/kendo-angular-intl @progress/kendo-angular-l10n @progress/kendo-angular-label @progress/kendo-drawing @progress/kendo-angular-excel-export @progress/kendo-angular-buttons @progress/kendo-angular-common @progress/kendo-angular-pdf-export @progress/kendo-angular-popup @progress/kendo-date-math @progress/kendo-licensing @progress/kendo-angular-icons
-
Тo add the Gantt component, import the
GanttModule
in your root application or feature module.import { NgModule } from "@angular/core"; import { BrowserModule } from "@angular/platform-browser"; import { BrowserAnimationsModule } from "@angular/platform-browser/animations"; import { GanttModule } from "@progress/kendo-angular-gantt"; import { AppComponent } from "./app.component"; @NgModule({ imports: [ BrowserModule, BrowserAnimationsModule, GanttModule, ], declarations: [AppComponent], bootstrap: [AppComponent], }) export class AppModule {}
-
The next step is to style the component by installing one of the available Kendo UI themes—Kendo UI Default, Kendo UI Material, or Kendo UI Bootstrap.
3.1 To start using a theme, install its package through NPM.
-
Default theme
npm install --save @progress/kendo-theme-default
-
Bootstrap theme
npm install --save @progress/kendo-theme-bootstrap
-
Material theme
npm install --save @progress/kendo-theme-material
3.2 After the theme package is installed, reference it in your project. You can include
kendo-themes
in your project in one of the following ways:- By using an external (CDN) link
- By using a precompiled CSS file
- By compiling the theme from the SCSS source files
-
Using the Component
-
After successfully installing the Gantt package and importing its module, add the following code in the
app.component.html
file:<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
kendoGanttHierarchyBinding
directive to an array of data items representing the Gantt tasks by adding the following code in theapp.component.ts
file:public 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
dependencies
input to an array of task dependencies by adding the following code in theapp.component.ts
file:public 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.
ng 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
- 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
Dependencies
The following table lists the specific functionalities that are provided by each of the Gantt dependencies as per package:
Package Name | Description |
---|---|
@angular/common | Provides the commonly-needed services, pipes, and directives provided by the Angular team. For more information, refer to the official Angular documentation. |
@angular/core | Contains critical runtime parts of the Angular framework that are needed by every application. For more information, refer to the official Angular documentation. |
@angular/forms | Provides support for both template-driven and reactive forms. For more information, refer to the official Angular documentation. |
@angular/animations | Contains the library of Angular animations. For more information, refer to the official Angular documentation. |
@angular/platform-browser | Contains all DOM- and browser-related utilities for executing Angular applications on different browsers. For more information, refer to the official Angular documentation. |
@progress/kendo-angular-treelist | Contains the Kendo UI for Angular TreeList component. |
@progress/kendo-angular-dialog | Contains the Kendo UI for Angular Dialog components. |
@progress/kendo-angular-buttons | Contains the Kendo UI for Angular Buttons components. |
@progress/kendo-angular-common | Contains common utilities that are needed by every Kendo UI for Angular component. |
@progress/kendo-angular-dateinputs | Contains the Kendo UI for Angular Date Inputs components. |
@progress/kendo-angular-dropdowns | Contains the Kendo UI for Angular Dropdowns components. |
@progress/kendo-angular-excel-export | Contains the Kendo UI for Angular Excel Export component. |
@progress/kendo-angular-inputs | Contains the Kendo UI for Angular Inputs components. |
@progress/kendo-angular-intl | Provides the Kendo UI for Angular services and pipes for the parsing and formatting of dates and numbers. |
@progress/kendo-angular-l10n | Provides the globalization features of Kendo UI for Angular. |
@progress/kendo-angular-label | Contains the Kendo UI for Angular Labels components. |
@progress/kendo-angular-layout | Contains the Kendo UI for Angular Layout components. |
@progress/kendo-angular-pdf-export | Contains the Kendo UI for Angular PDF Export component. |
@progress/kendo-angular-popup | Contains the Kendo UI for Angular Popup components. |
@progress/kendo-angular-progressbar | Contains the Kendo UI for Angular ProgressBar components. |
@progress/kendo-angular-treeview | Contains the Kendo UI for Angular TreeView component. |
@progress/kendo-angular-icons | Contains the Kendo UI for Angular Icons. |
@progress/kendo-data-query | Contains the Kendo UI Data Query utilities for applying sorting, filtering, grouping, and aggregate data operations. |
@progress/kendo-date-math | Contains the Kendo UI Date Math utilities for exporting functions which support date manipulation tasks. |
@progress/kendo-drawing | Provides the Kendo UI cross-browser library for interactive vector graphics. |
@progress/kendo-licensing | Contains the kendo-ui-license CLI Tool for license management and the validatePackage function and type definitions that are used by licensed packages. |
rxjs | Provides the RxJS library for reactive programming which uses Observables for an easier composition of asynchronous or callback-based code. |