# Getting Started with the Kendo UI for Angular Diagram

This guide provides the information you need to start using the Kendo UI for Angular Diagram—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 components](https://angular.dev/guide/components/importing) enabled by default. If you use `NgModules`, refer to these articles:
>
> * [Using Kendo Angular Components with NgModules](https://www.telerik.com/kendo-angular-ui-develop/components/installation/using-modules)
> * [Using Hybrid Configuration](https://www.telerik.com/kendo-angular-ui-develop/components/installation/using-modules#ngmodules-vs-standalone-components-pros-and-cons-in-kendo-ui-for-angular)

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.

<CtaPanelOverview></CtaPanelOverview>

After the completion of this guide, you will be able to achieve a basic setup with `Shapes`, `Connections`, and a `Layout` in the Kendo UI for Angular Diagram component in your Angular application.

[Demo Source](https://demos.telerik.com/kendo-angular-ui/demos/diagrams/getting-started/source.txt)

## Before You Begin

Before you start with the installation of any Kendo UI for Angular components, ensure that you have a running Angular project. The component installation prerequisites 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](https://www.telerik.com/kendo-angular-ui-develop/components/getting-started#quick-start).

## Installing the Components

The following command demonstrates an efficient, automated method for adding packages using the [Angular CLI](https://angular.dev/tools/cli) through the [`ng-add`](https://angular.dev/tools/cli/schematics-for-libraries#providing-installation-support) 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](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams/installation/manual-setup) for more details on the individual commands.

To add the Kendo UI for Angular Diagrams package:

1. Run the following command.

   ```sh
   ng add @progress/kendo-angular-diagrams
   ```

   As a result, the `ng-add` command will perform the following actions:

   * Add the `@progress/kendo-angular-diagrams` package as a dependency to the `package.json` file.
   * Add all required [peer dependencies](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams/installation/dependencies-and-utils#kendo-angular-diagram-dependencies) to the `package.json` file.
   * Register the [Kendo UI Meridian theme](https://www.telerik.com/kendo-angular-ui-develop/components/styling#including-a-theme) in the `angular.json` file.
   * Trigger `npm install` to install the theme and all peer packages that are added.

2. Import the required components, directives and utility arrays:

   > The utility arrays are 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](https://www.telerik.com/kendo-angular-ui-develop/components/installation/using-modules) article.

   To add the Diagram component, import the `KENDO_DIAGRAM` utility array in your standalone component.

   ```ts
   import { Component } from '@angular/core';
   import { KENDO_DIAGRAM } from '@progress/kendo-angular-diagrams';

   @Component({
       standalone: true,
       selector: 'my-app',
       imports: [KENDO_DIAGRAM]
   })
   ```

## Using the Components

1. After successfully installing the Diagram package and importing the required components and directives, add the corresponding tags of the components you need in the `app.component.html`. For example, if you need the Diagram, add the following code:

   ```html
   <kendo-diagram
       [shapes]="shapes"
       [connections]="connections"
       [layout]="{type: 'tree'}"
       height="400px">
   </kendo-diagram>
   ```

2. Define the shapes and connections data in your component:

   ```typescript
   import { Component } from '@angular/core';
   import { KENDO_DIAGRAM, ShapeOptions, ConnectionOptions } from '@progress/kendo-angular-diagrams';

   @Component({
       standalone: true,
       imports: [KENDO_DIAGRAM],
       selector: 'my-app',
       template: `
           <kendo-diagram
               [shapes]="shapes"
               [connections]="connections"
               [layout]="{type: 'tree'}"
               height="400px">
           </kendo-diagram>
       `
   })
   export class AppComponent {
       public shapes: ShapeOptions[] = [
           {
               id: 'shape1',
               content: {
                   text: 'Start'
               }
           },
           {
               id: 'shape2',
               content: {
                   text: 'Process'
               }
           },
           {
               id: 'shape3',
               content: {
                   text: 'End'
               }
           }
       ];

       public connections: ConnectionOptions[] = [
           {
               from: 'shape1',
               to: 'shape2'
           },
           {
               from: 'shape2',
               to: 'shape3'
           }
       ];
   }
   ```

3. Build and serve the application by running the following command in the root folder.

   ```sh
   ng serve
   ```

4. Point your browser to [http://localhost:4200](http://localhost:4200/) to see the Kendo UI for Angular Diagram 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](https://www.telerik.com/kendo-angular-ui-develop/components/licensing).

## Next Steps

* [Diagram Overview](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams)
* [Diagram Data Binding](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams/data-binding)
* [Workflow Diagram](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams/workflow-diagram)
* [Diagram Shapes](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams/shapes)
* [Diagram Connections](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams/connections)
* [Diagram Layouts](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams/layouts)
* [Diagram Export Options](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams/pdf-export)
* [Diagram Events](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams/events)

## Learning Resources

* [Diagrams Overview](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams)
* [API Reference of the Angular Diagrams](https://www.telerik.com/kendo-angular-ui-develop/components/diagrams/api)
* [Get Started with Kendo UI for Angular](https://www.telerik.com/kendo-angular-ui-develop/components/getting-started)
* [Using Kendo UI for Angular with Angular CLI](https://www.telerik.com/kendo-angular-ui-develop/components/installation/angular-cli)
* [Styling Overview](https://www.telerik.com/kendo-angular-ui-develop/components/styling)
* [Theme Builder](https://www.telerik.com/kendo-angular-ui-develop/components/styling/theme-builder)
* [Customizing the Themes](https://www.telerik.com/kendo-angular-ui-develop/components/styling/custom-themes)
* [Activating Your License Key](https://www.telerik.com/kendo-angular-ui-develop/components/licensing)
* [Video Courses](https://www.telerik.com/kendo-angular-ui-develop/components/getting-started/video-onboarding)
