Getting started with Angular Diagram component
10 Dec 202424 minutes to read
This section explains you the steps required to create a simple diagram and demonstrate the basic usage of the diagram control.
Prerequisites
System requirements for Syncfusion® Angular UI components
Dependencies
The following list of dependencies are required to use the Diagram
component in your application.
|-- @syncfusion/ej2-angular-diagrams
|-- @syncfusion/ej2-base
|-- @syncfusion/ej2-data
|-- @syncfusion/ej2-navigations
|-- @syncfusion/ej2-inputs
|-- @syncfusion/ej2-popups
|-- @syncfusion/ej2-buttons
|-- @syncfusion/ej2-lists
|-- @syncfusion/ej2-splitbuttons
Setup Angular Environment
You can use Angular CLI
to setup your Angular applications.
To install Angular CLI use the following command.
npm install -g @angular/cli
Create an Angular Application
Start a new Angular application using below Angular CLI command.
ng new my-diagram-app
cd my-diagram-app
Installing Syncfusion® Diagram package
All the available Essential® JS 2 packages are published in npmjs.com registry.
To install Diagram component, use the following command.
npm install @syncfusion/ej2-angular-diagrams --save
NOTE
The –save will instruct NPM to include the diagram package inside of the dependencies section of the package.json.
Registering Diagram Module
Import Diagram module into Angular application(app.component.ts) from the package @syncfusion/ej2-angular-diagrams
[src/app/app.component.ts].
import { DiagramModule } from '@syncfusion/ej2-angular-diagrams';
import { Component } from "@angular/core";
@Component({
//Import Diagram module
imports: [
DiagramModule
],
providers: [ ],
standalone: true,
selector: "app-container",
// specifies the template string for the diagram component
template: `<ejs-diagram id="diagram" width="100%" height="580px"></ejs-diagram>`,
})
export class AppComponent {}
Adding CSS reference
Combined CSS files are available in the Essential® JS 2 package root folder. This can be referenced in [src/styles.css] using following code.
@import '../node_modules/@syncfusion/ej2-angular-diagrams/styles/material.css';
@import "../node_modules/@syncfusion/ej2-angular-base/styles/material.css";
@import "../node_modules/@syncfusion/ej2-popups/styles/material.css";
@import "../node_modules/@syncfusion/ej2-splitbuttons/styles/material.css";
@import "../node_modules/@syncfusion/ej2-navigations/styles/material.css";
Add Diagram component
Modify the template in [src/app/app.component.ts] file to render the diagram component. Add the Angular Diagram by using <ejs-diagram>
selector in template
section of the app.component.ts file.
import { DiagramModule } from '@syncfusion/ej2-angular-diagrams';
import { Component } from "@angular/core";
@Component({
//Import Diagram module
imports: [
DiagramModule
],
providers: [ ],
standalone: true,
selector: "app-container",
// specifies the template string for the diagram component
template: `<ejs-diagram id="diagram" width="100%" height="580px"></ejs-diagram>`,
})
export class AppComponent {}
Module Injection
The diagram component is divided into individual feature-wise modules. In order to use a particular feature, inject the required module. The following list describes the module names and their description.
-
BpmnDiagramsService
- Inject this provider to add built-in BPMN Shapes to diagrams. -
ConnectorBridgingService
- Inject this provider to add bridges to connectors. -
ConnectorEditingService
- Inject this provider to edit the segments for connector. -
ComplexHierarchicalTreeService
- Inject this provider to complex hierarchical tree like structure. -
DataBindingService
- Inject this provider to populate nodes from given data source. -
DiagramContextMenuService
- Inject this provider to manipulate context menu. -
HierarchicalTreeService
- Inject this provider to use hierarchical tree like structure. -
LayoutAnimationService
- Inject this provider animation to layouts. -
MindMapService
- Inject this provider to use mind map. -
PrintAndExportService
- Inject this provider to print or export the objects. -
RadialTreeService
- Inject this provider to use Radial tree like structure. -
SnappingService
- Inject this provider to Snap the objects. -
SymmetricLayoutService
- Inject this provider to render layout in symmetrical method. -
UndoRedoService
- Inject this provider to revert and restore the changes. -
Ej1SerializationService
- Inject this provider to load ej1 diagram json in ej2 diagram.
These modules should be injected into the providers section of root NgModule or component class.
import { BpmnDiagramsService, ComplexHierarchicalTreeService, ConnectorBridgingService, ConnectorEditingService, DataBindingService, DiagramContextMenuService, DiagramModule, Ej1SerializationService, HierarchicalTreeService, LayoutAnimationService, MindMapService, PrintAndExportService, RadialTreeService, SnappingService, SymmetricLayoutService, UndoRedoService } from '@syncfusion/ej2-angular-diagrams';
import { Component } from "@angular/core";
@Component({
imports: [
DiagramModule
],
providers: [ HierarchicalTreeService, MindMapService, RadialTreeService, ComplexHierarchicalTreeService, DataBindingService, SnappingService, PrintAndExportService, BpmnDiagramsService, SymmetricLayoutService, ConnectorBridgingService, UndoRedoService, LayoutAnimationService, DiagramContextMenuService, ConnectorEditingService,Ej1SerializationService ],
standalone: true,
selector: "app-container",
// specifies the template string for the diagram component
template: `<ejs-diagram id="diagram" width="100%" height="400px"></ejs-diagram>`,
})
export class AppComponent {}
Defining Basic Diagram
The below example shows a basic diagram which renders an empty diagram.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { DiagramModule } from '@syncfusion/ej2-angular-diagrams'
import { Component } from "@angular/core";
@Component({
imports: [
DiagramModule
],
providers: [ ],
standalone: true,
selector: "app-container",
// specifies the template string for the diagram component
template: `<ejs-diagram id="diagram" width="100%" height="580px"></ejs-diagram>`
})
export class AppComponent {}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Now, run the application by using npm start command. Open the browser with the generated link and you can see an empty diagram.
npm start
NOTE
The selector specified in the @Component decorator of the app.component.ts file must match the custom element tag used in the index.html file. For example, if your @Component decorator includes the selector “app-container”, your index.html file should include an element
<app-container></app-container>
.
Basic Diagram elements
-
Node
: Visualizes any graphical object using nodes, which can also be arranged and manipulated on a diagram page. -
Connector
: Represents the relationship between two nodes. Three types of connectors provided as follows:
1) Orthogonal
2) Bezier
3) Straight
-
Port
: Acts as the connection points of node or connector and allows you to create connections with only specific points. -
Annotation
: Shows additional information by adding text or labels on nodes and connectors.
Flow Diagram
Create and Add Node to the diagram
Create and add a node
(JSON data) with specific position, size, label, and shape.
import { DiagramComponent, DiagramModule } from '@syncfusion/ej2-angular-diagrams'
import { Component, ViewEncapsulation, ViewChild } from "@angular/core";
@Component({
imports: [
DiagramModule
],
providers: [ ],
standalone: true,
selector: "app-container",
template: `<ejs-diagram id="diagram" width="100%" height="580px" mode="SVG">
<e-nodes>
<e-node id='node1' [height]=60 [width]=100 [offsetX]=300 [offsetY]=80 >
<e-node-annotations>
<e-node-annotation content='Start'></e-node-annotation>
</e-node-annotations>
</e-node>
</e-nodes>
</ejs-diagram>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
@ViewChild("diagram")
public diagram?: DiagramComponent;
ngOnInit(): void {
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Apply shape and style to node
Syncfusion® diagram control provides support to render many built-in shapes in diagram.
Please refer to Shapes
to know about built-in Shapes.
The appearance of a node can be customized by changing its fill
color, strokeColor
, strokeWidth
, borderColor
, borderWidth
, strokeDashArray
, opacity
, and shadow
.
import { DiagramComponent, DiagramModule, FlowShapeModel } from '@syncfusion/ej2-angular-diagrams'
import { Component, ViewEncapsulation, ViewChild } from "@angular/core";
@Component({
imports: [
DiagramModule
],
providers: [ ],
standalone: true,
selector: "app-container",
template: `<ejs-diagram id="diagram" width="100%" height="580px" mode="SVG">
<e-nodes>
<e-node id='node1' [height]=60 [width]=100 [offsetX]=300 [offsetY]=80 [shape]='shape' [style]='style' [borderColor]='borderColor' [borderWidth]='borderWidth'>
<e-node-annotations>
<e-node-annotation content='Start'></e-node-annotation>
</e-node-annotations>
</e-node>
</e-nodes>
</ejs-diagram>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
@ViewChild("diagram")
public Diagram?: DiagramComponent;
public shape:FlowShapeModel = { type: 'Flow', shape: 'Terminator'};
public borderColor = 'orange';
public borderWidth = 10;
public style = {fill:'red',strokeColor:'green',strokeWidth:5,strokeDashArray:'2 2'};
ngOnInit(): void {
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Add other flowchart nodes to the diagram
You can add multiple nodes with different shapes into diagram.
import { DiagramComponent, DiagramModule } from '@syncfusion/ej2-angular-diagrams'
import { Component, ViewEncapsulation, ViewChild } from "@angular/core";
import {
FlowShapeModel,
NodeModel,
ConnectorModel,
} from "@syncfusion/ej2-angular-diagrams";
@Component({
imports: [
DiagramModule
],
providers: [ ],
standalone: true,
selector: "app-container",
template: `<ejs-diagram id="diagram" width="100%" height="580px" [getNodeDefaults]='nodeDefaults' [getConnectorDefaults]='connectorDefaults'>
<e-nodes>
<e-node id='node1' [offsetX]=300 [offsetY]=50 [shape]='terminator'>
<e-node-annotations>
<e-node-annotation content='Start'></e-node-annotation>
</e-node-annotations>
</e-node>
<e-node id='node2' [offsetX]=300 [offsetY]=140 [shape]='process'>
<e-node-annotations>
<e-node-annotation content='var i = 0;'></e-node-annotation>
</e-node-annotations>
</e-node>
<e-node id='node3' [offsetX]=300 [offsetY]=230 [shape]='decision'>
<e-node-annotations>
<e-node-annotation content='i < 10?'></e-node-annotation>
</e-node-annotations>
</e-node>
</e-nodes>
</ejs-diagram>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
@ViewChild("diagram")
public diagram?: DiagramComponent;
public terminator?: FlowShapeModel;
public process?: FlowShapeModel;
public decision?: FlowShapeModel;
public nodeDefaults(node: NodeModel): NodeModel {
node.height = 50;
node.width = 140;
node.style = {fill:'skyblue', strokeColor: 'skyblue'};
return node;
}
public connectorDefaults(obj: ConnectorModel): ConnectorModel {
obj.type = "Orthogonal";
obj.targetDecorator = { shape: "Arrow", width: 10, height: 10 };
return obj;
}
ngOnInit(): void {
this.terminator = { type: 'Flow', shape: 'Terminator' };
this.process = { type: 'Flow', shape: 'Process' };
this.decision = { type: 'Flow', shape: 'Decision' };
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Connect flow chart nodes
Connect these nodes by adding a connector using the connectors
property of diagram and refer the source and target end by using the sourceID
and targetID
properties.
The required nodes and connectors can be added to form a complete flow diagram.
import { NgModule } from '@angular/core'
import { BrowserModule } from '@angular/platform-browser'
import { DiagramComponent, DiagramModule } from '@syncfusion/ej2-angular-diagrams'
import { Component, ViewEncapsulation, ViewChild } from "@angular/core";
import {
FlowShapeModel,
NodeModel,
ConnectorModel,
OrthogonalSegmentModel
} from "@syncfusion/ej2-angular-diagrams";
@Component({
imports: [
DiagramModule
],
providers: [ ],
standalone: true,
selector: "app-container",
template: `<ejs-diagram id="diagram" width="100%" height="580px" [getNodeDefaults]='nodeDefaults' [getConnectorDefaults]='connectorDefaults'>
<e-nodes>
<e-node id='node1' [offsetX]=300 [offsetY]=50 [shape]='terminator'>
<e-node-annotations>
<e-node-annotation content='Start'></e-node-annotation>
</e-node-annotations>
</e-node>
<e-node id='node2' [offsetX]=300 [offsetY]=140 [shape]='process'>
<e-node-annotations>
<e-node-annotation content='var i = 0;'></e-node-annotation>
</e-node-annotations>
</e-node>
<e-node id='node3' [offsetX]=300 [offsetY]=230 [shape]='decision'>
<e-node-annotations>
<e-node-annotation content='i < 10?'></e-node-annotation>
</e-node-annotations>
</e-node>
<e-node id='node4' [offsetX]=100 [offsetY]=320 [shape]='preDefinedProcess'>
<e-node-annotations>
<e-node-annotation content='print(\"Hello!!\");'></e-node-annotation>
</e-node-annotations>
</e-node>
<e-node id='node5' [offsetX]=300 [offsetY]=410 [shape]='process'>
<e-node-annotations>
<e-node-annotation content='i++;'></e-node-annotation>
</e-node-annotations>
</e-node>
<e-node id='node6' [offsetX]=500 [offsetY]=500 [shape]='terminator'>
<e-node-annotations>
<e-node-annotation content='End'></e-node-annotation>
</e-node-annotations>
</e-node>
</e-nodes>
<e-connectors>
<e-connector id='connector1' sourceID='node1' targetID='node2'></e-connector>
<e-connector id='connector2' sourceID='node2' targetID='node3'></e-connector>
<e-connector id='connector3' sourceID='node3' targetID='node4'>
<e-connector-annotations>
<<e-connector-annotation content='Yes'></e-connector-annotation>
</e-connector-annotations>
</e-connector>
<e-connector id='connector4' sourceID='node3' targetID='node6' [segments]='segment1'>
<e-connector-annotations>
<e-connector-annotation content='No'></e-connector-annotation>
</e-connector-annotations>
</e-connector>
<e-connector id='connector5' sourceID='node4' targetID='node5'></e-connector>
<e-connector id='connector6' sourceID='node5' targetID='node3' [segments]='segment2'></e-connector>
</e-connectors>
</ejs-diagram>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
@ViewChild("diagram")
public diagram?: DiagramComponent;
public terminator?: FlowShapeModel;
public process?: FlowShapeModel;
public decision?: FlowShapeModel;
public preDefinedProcess?: FlowShapeModel;
public segment1?: OrthogonalSegmentModel;
public segment2?: OrthogonalSegmentModel;
public nodeDefaults(node: NodeModel): NodeModel {
node.height = 50;
node.width = 140;
node.offsetX = 300;
if(node.id === "node1" || node.id === "node4"){
node.style = { fill: "#357BD2", strokeColor: "white" };
}else if(node.id === "node2" || node.id === "node5"){
node.style = { fill: "yellow", strokeColor: "white" };
}else if(node.id === "node3"){
node.style = { fill: "#00FF00", strokeColor: "white" };
}else if(node.id === "node6"){
node.style = { fill: "red", strokeColor: "white" };
}
return node;
}
public connectorDefaults(obj: ConnectorModel): ConnectorModel {
obj.type = "Orthogonal";
obj.targetDecorator = { shape: "Arrow", width: 10, height: 10 };
return obj;
}
ngOnInit(): void {
this.terminator = { type: 'Flow', shape: 'Terminator' };
this.process = { type: 'Flow', shape: 'Process' };
this.decision = { type: 'Flow', shape: 'Decision' };
this.preDefinedProcess = { type: 'Flow', shape: 'PreDefinedProcess' };
this.segment1 = [{ length: 30, direction: "Right",type:'Orthogonal' }, { length: 300, direction: "Bottom",type:'Orthogonal' }];
this.segment2 = [{ length: 30, direction: "Left",type:'Orthogonal' }, { length: 200, direction: "Top",type:'Orthogonal' }];
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Default values for all nodes
and connectors
can be set using the getNodeDefaults
and getConnectorDefaults
properties, respectively. For example, if all nodes have the same width and height, such properties can be moved into getNodeDefaults
.
Automatic Organization Chart
In the ‘Flow Diagram’ section, how to create a diagram manually was discussed. This section explains how to create and position the diagram automatically.
Business object (Employee information)
Define Employee Information as JSON data. The following code example shows an employee array whose, Name
is used as an unique identifier and ReportingPerson
is used to identify the person to whom an employee report to, in the organization.
public data: Object[] = [
{
Name: "Elizabeth",
Role: "Director"
},
{
Name: "Christina",
ReportingPerson: "Elizabeth",
Role: "Manager"
},
{
Name: "Yoshi",
ReportingPerson: "Christina",
Role: "Lead"
},
{
Name: "Philip",
ReportingPerson: "Christina",
Role: "Lead"
},
{
Name: "Yang",
ReportingPerson: "Elizabeth",
Role: "Manager"
},
{
Name: "Roland",
ReportingPerson: "Yang",
Role: "Lead"
},
{
Name: "Yvonne",
ReportingPerson: "Yang",
Role: "Lead"
}
];
Map data source
You can configure the above “Employee Information” with diagram, so that the nodes and connectors are automatically generated using the mapping properties. The following code example demonstrates how to use dataSourceSettings
to map id
and parentId
with the corresponding property names of employee information.
@Component({
selector: "app-container",
template: `<ejs-diagram id="diagram" width="100%" height="580px" [dataSourceSettings]='dataSourceSettings'></ejs-diagram>`
})
export class AppComponent {
@ViewChild("diagram")
public dataSourceSettings: DataSourceModel;
public data: Object[] = [
{
Name: "Elizabeth",
Role: "Director"
},
{
Name: "Christina",
ReportingPerson: "Elizabeth",
Role: "Manager"
},
{
Name: "Yoshi",
ReportingPerson: "Christina",
Role: "Lead"
},
{
Name: "Philip",
ReportingPerson: "Christina",
Role: "Lead"
},
{
Name: "Yang",
ReportingPerson: "Elizabeth",
Role: "Manager"
},
{
Name: "Roland",
ReportingPerson: "Yang",
Role: "Lead"
},
{
Name: "Yvonne",
ReportingPerson: "Yang",
Role: "Lead"
}
];
ngOnInit(): void {
this.dataSourceSettings = {
id: "Name",
parentId: "ReportingPerson",
dataManager: new DataManager(this.data as JSON[])
};
}
}
Rendering layout with Datasource
To create an organizational chart, the type
of layout should be set as an OrganizationalChart
. The following code example shows how DataManager is used to generate Layout based on the DataSourceSettings of the Diagram.
import { ConnectorModel, DataBinding, DataSourceModel, Diagram, DiagramComponent, DiagramModule,HierarchicalTree,LayoutModel, NodeModel, ShapeStyleModel } from '@syncfusion/ej2-angular-diagrams'
import { Component, ViewEncapsulation, ViewChild } from "@angular/core";
import { DataManager } from "@syncfusion/ej2-data";
export interface EmployeeInfo {
Name: string;
Role: string;
color: string;
}
Diagram.Inject(DataBinding,HierarchicalTree);
@Component({
imports: [
DiagramModule
],
standalone: true,
selector: "app-container",
template: `<ejs-diagram id="diagram" width="100%" height="580px" [layout]='layout' [dataSourceSettings]='dataSourceSettings' [getNodeDefaults]='nodeDefaults' [getConnectorDefaults]='connectorDefaults'>
</ejs-diagram>`
})
export class AppComponent {
@ViewChild("diagram")
public diagram?: DiagramComponent;
public data: Object[] = [
{
Name: "Elizabeth",
Role: "Director",
ReportingPerson:null
},
{
Name: "Christina",
ReportingPerson: "Elizabeth",
Role: "Manager"
},
{
Name: "Yoshi",
ReportingPerson: "Christina",
Role: "Lead"
},
{
Name: "Philip",
ReportingPerson: "Christina",
Role: "Lead"
},
{
Name: "Yang",
ReportingPerson: "Elizabeth",
Role: "Manager"
},
{
Name: "Roland",
ReportingPerson: "Yang",
Role: "Lead"
},
{
Name: "Yvonne",
ReportingPerson: "Yang",
Role: "Lead"
}
];
public dataSourceSettings?: DataSourceModel = {
id: "Name",
parentId: "ReportingPerson",
dataManager: new DataManager(this.data as JSON[]),
doBinding: (nodeModel: NodeModel, data: object) => {
nodeModel.annotations = [
{ content: (data as EmployeeInfo).Name, style: { color: "white" } }
];
}
};
public layout: LayoutModel = {
type:'OrganizationalChart'
};
public nodeDefaults(node: NodeModel): NodeModel {
let codes: Object = {
Director: "rgb(0, 139,139)",
Manager: "rgb(30, 30,113)",
Lead: "rgb(0, 100,0)"
};
node.width = 70;
node.height = 30;
node.annotations = [
{ content: (node.data as EmployeeInfo).Name, style: { color: "white" } }
];
((node as NodeModel).style as ShapeStyleModel).fill = (codes as any)[(node.data as EmployeeInfo).Role] as string;
return node;
}
public connectorDefaults(connector: ConnectorModel): ConnectorModel {
connector.type = "Orthogonal";
connector.cornerRadius = 7;
return connector;
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
Customize employee appearance
The following code examples indicate how to define the default appearance of nodes and connectors. The setNodeTemplate
is used to update each node based on employee data.
import { ConnectorModel, DataBinding, DataSourceModel, Diagram, DiagramComponent, DiagramModule, HierarchicalTree, ImageElement, LayoutModel, NodeModel, StackPanel, TextElement } from '@syncfusion/ej2-angular-diagrams'
import { Component, ViewEncapsulation, ViewChild } from "@angular/core";
import { DataManager } from "@syncfusion/ej2-data";
export interface EmployeeInfo {
Name: string;
Role: string;
color: string;
}
Diagram.Inject(HierarchicalTree,DataBinding);
@Component({
imports: [
DiagramModule
],
standalone: true,
selector: "app-container",
template: `<ejs-diagram id="diagram" width="100%" height="580px" [layout]='layout' [dataSourceSettings]='dataSourceSettings'
[getConnectorDefaults]='connectorDefaults' [setNodeTemplate]='setNodeTemplate'>
</ejs-diagram>`,
encapsulation: ViewEncapsulation.None
})
export class AppComponent {
@ViewChild("diagram")
public diagram?: DiagramComponent;
public data: Object[] = [
{
Name: "Elizabeth",
Role: "Director",
ReportingPerson:null
},
{
Name: "Christina",
ReportingPerson: "Elizabeth",
Role: "Manager"
},
{
Name: "Yoshi",
ReportingPerson: "Christina",
Role: "Lead"
},
{
Name: "Philip",
ReportingPerson: "Christina",
Role: "Lead"
},
{
Name: "Yang",
ReportingPerson: "Elizabeth",
Role: "Manager"
},
{
Name: "Roland",
ReportingPerson: "Yang",
Role: "Lead"
},
{
Name: "Yvonne",
ReportingPerson: "Yang",
Role: "Lead"
}
];
public dataSourceSettings?: DataSourceModel = {
id: "Name",
parentId: "ReportingPerson",
dataManager: new DataManager(this.data as JSON[]),
};
public layout: LayoutModel = {
type:'OrganizationalChart'
};
public connectorDefaults(connector: ConnectorModel): ConnectorModel {
connector.type = "Orthogonal";
connector.cornerRadius = 7;
return connector;
}
public setNodeTemplate(node: NodeModel) {
let codes: Object = {
Director: "rgb(0, 139,139)",
Manager: "rgb(30, 30,113)",
Lead: "rgb(0, 100,0)"
};
let content = new StackPanel();
content.id = node.id + "_outerstack";
content.orientation = "Horizontal";
content.style.strokeColor = "gray";
content.style.fill = (codes as any)[(node.data as EmployeeInfo).Role] as string;
content.padding = { left: 5, right: 5, top: 5, bottom: 5}
let innerContent = new ImageElement();
innerContent.style.strokeColor = "blue";
innerContent.id = node.id + "_innerstack";
innerContent.style.fill = "skyblue";
innerContent.width = 50;
innerContent.height = 50;
let text = new TextElement();
text.id = node.id + "_text";
text.content = (node.data as EmployeeInfo).Name;
text.margin = { left: 15, right: 5, top: 5, bottom: 5}
text.style.color = "black";
content.children = [innerContent, text];
return content;
}
}
import { bootstrapApplication } from '@angular/platform-browser';
import { AppComponent } from './app.component';
import 'zone.js';
bootstrapApplication(AppComponent).catch((err) => console.error(err));
NOTE
Please note that project generated through angular CLI project will always the changes made into application and compiled it automatically. We don’t need to run “npm start” command for each changes made into the application.