-
AI-powered Extensions
-
Data Grid
-
Tree List
-
Chat
-
HTML Editor
-
Form
-
-
Data Grids / Data Management
-
Data Grid
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Grouping
-
Selection
- Focused Row
- Paging
-
Scrolling
-
Columns
- AI Assistant
-
Master-Detail
-
Data Summaries
-
Drag & Drop
-
Export to PDF
-
Export to Excel
- Appearance
-
Customization
- State Persistence
-
Adaptability
-
Keyboard Navigation
- Right-To-Left Support
-
Tree List
- Overview
-
Data Binding
-
Filtering
- Sorting
-
Editing
-
Selection
- Focused Row
- Paging
-
Columns
- Drag & Drop
- State Persistence
- Adaptability
-
Keyboard Navigation
-
Card View
-
Pivot Grid
- Overview
-
Data Binding
-
Field Management
-
Data Summaries
- Drill Down
- Filtering
-
Scrolling
-
Export to Excel
- Chart Integration
- Customization
- State Persistence
-
Filter Builder
-
-
Data Visualization
-
Charts
- Overview
-
Data Binding
-
Common Concepts
-
Axis
-
Aggregation
-
Tooltips
-
Selection
-
Customization
-
Zooming
-
Export
-
-
Area Charts
-
Bar Charts
- Bullet Charts
-
Doughnut Charts
-
Financial Charts
-
Funnel and Pyramid Charts
-
Line Charts
- Pareto Chart
-
Pie Charts
-
Point Charts
-
Polar and Radar Charts
-
Range Charts
- Sankey Chart
-
Sparkline Charts
-
Tree Map
-
Gauges
- Overview
-
Runtime update
-
Bar Gauge
-
Circular Gauge
-
Linear Gauge
-
Diagram
- Overview
-
Data Binding
-
Featured Shapes
-
Custom Shapes
-
Document Capabilities
-
User Interaction
- UI Customization
- Adaptability
-
-
Scheduling / Planning
-
Scheduler
- Overview
-
Data Binding
-
Views
-
Appointments
-
Timetable
- Editing
-
Grouping
- Virtual Scrolling
- Drag & Drop
-
Customization
- Adaptability
-
Gantt
- Overview
- Data Binding
-
Filtering
- Sorting
- Strip Lines
- Export to PDF
- Validation
-
Customization
-
-
Messaging
-
WYSIWYG Editor
-
Forms
-
Data Editors
- Overview
-
Common Concepts
-
Calendar
- Check Box
- Color Box
-
Date Box
-
Date Range Box
-
Number Box
- Radio Group
-
Range Selector
- Range Slider
- Slider
- Switch
- Text Area
- Text Box
-
Drop-Downs
- Autocomplete
-
Drop Down Box
-
Select Box
-
Tag Box
-
Lookup
-
Buttons
-
File Upload / File Management
-
File Manager
- Overview
-
File System Types
-
Customization
-
File Uploader
-
-
Popup and Notifications
-
Navigation
- Overview
- Accordion
-
Action Sheet
-
Context Menu
-
Menu
- Multi View
-
Drawer
-
Tab Panel
-
Tabs
-
Toolbar
-
Stepper
- Pagination
-
List
-
Tree View
- Right-to-Left Support
-
Layout
-
Tile View
- Splitter
-
Gallery
- Scroll View
- Box
- Responsive Box
-
-
Interactive Wrappers
-
Sortable
- Resizable
-
-
Progress Indicators
-
Maps
- Overview
-
Map
-
Vector Map
-
Data Binding
- Multiple Layers
-
Markers
- Legend
-
Zooming and Panning
-
Customization
-
-
Localization
Related Demos:
Your search did not match any results.
Angular Diagram - Advanced Data Binding
The Diagram component accepts functions as expression property values. It allows you to implement custom logic when you bind a diagram to a data source.
In this demo, the nodes and edges collections are bound to a data source. Custom functions are used to get different shape types and font styles for items based on additional data source information.
The autoLayout property specifies an auto-layout algorithm type and orientation that the component uses to build diagrams.
Backend API
<dx-diagram #diagram id="diagram">
<dxo-diagram-nodes
[dataSource]="orgItemsDataSource"
keyExpr="ID"
[typeExpr]="itemTypeExpr"
textExpr="Name"
[widthExpr]="itemWidthExpr"
[heightExpr]="itemHeightExpr"
[textStyleExpr]="itemTextStyleExpr"
[styleExpr]="itemStyleExpr"
>
<dxo-diagram-auto-layout
type="tree"
orientation="horizontal"
></dxo-diagram-auto-layout>
</dxo-diagram-nodes>
<dxo-diagram-edges
[dataSource]="orgLinksDataSource"
keyExpr="ID"
fromExpr="From"
toExpr="To"
[styleExpr]="linkStyleExpr"
[fromLineEndExpr]="linkFromLineEndExpr"
[toLineEndExpr]="linkToLineEndExpr"
></dxo-diagram-edges>
<dxo-diagram-toolbox>
<dxi-diagram-group category="general" title="General"></dxi-diagram-group>
</dxo-diagram-toolbox>
</dx-diagram>
import { bootstrapApplication } from '@angular/platform-browser';
import { Component, enableProdMode, provideZoneChangeDetection } from '@angular/core';
import { provideHttpClient, withFetch } from '@angular/common/http';
import { DxDiagramModule } from 'devextreme-angular';
import { ArrayStore } from 'devextreme-angular/common/data';
import { Service } from './app.service';
if (!/localhost/.test(document.location.host)) {
enableProdMode();
}
@Component({
selector: 'demo-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
providers: [Service],
preserveWhitespaces: true,
imports: [
DxDiagramModule,
],
})
export class AppComponent {
orgItemsDataSource: ArrayStore;
orgLinksDataSource: ArrayStore;
constructor(service: Service) {
this.orgItemsDataSource = new ArrayStore({
key: 'ID',
data: service.getOrgItems(),
});
this.orgLinksDataSource = new ArrayStore({
key: 'ID',
data: service.getOrgLinks(),
});
}
itemTypeExpr(obj, value) {
if (value) {
obj.Type = (value === 'rectangle') ? undefined : 'group';
return null;
}
return obj.Type === 'group' ? 'ellipse' : 'rectangle';
}
itemWidthExpr(obj, value) {
if (value) {
obj.Width = value;
return null;
}
return obj.Width || (obj.Type === 'group' && 1.5) || 1;
}
itemHeightExpr(obj, value) {
if (value) {
obj.Height = value;
return null;
}
return obj.Height || (obj.Type === 'group' && 1) || 0.75;
}
itemTextStyleExpr(obj) {
if (obj.Level === 'senior') { return { 'font-weight': 'bold', 'text-decoration': 'underline' }; }
return {};
}
itemStyleExpr(obj) {
const style: Record<string, string> = { stroke: '#444444' };
if (obj.Type === 'group') { style.fill = '#f3f3f3'; }
return style;
}
linkStyleExpr() {
return { stroke: '#444444' };
}
linkFromLineEndExpr() {
return 'none';
}
linkToLineEndExpr() {
return 'none';
}
}
bootstrapApplication(AppComponent, {
providers: [
provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }),
provideHttpClient(withFetch()),
],
});
::ng-deep #diagram {
height: 900px;
}
import { Injectable } from '@angular/core';
export class OrgItem {
ID: string;
Name: string;
Type?: string;
Level?: string;
}
export class OrgLink {
ID: string;
From: string;
To: string;
}
const orgItems: OrgItem[] = [
{
ID: '106',
Name: 'Development',
Type: 'group',
},
{
ID: '107',
Name: 'WinForms\nTeam',
Type: 'group',
},
{
ID: '108',
Name: 'WPF\nTeam',
Type: 'group',
},
{
ID: '109',
Name: 'Javascript\nTeam',
Type: 'group',
},
{
ID: '110',
Name: 'ASP.NET\nTeam',
Type: 'group',
},
{
ID: '112',
Name: 'Ana\nTrujillo',
Level: 'senior',
},
{
ID: '113',
Name: 'Antonio\nMoreno',
},
{
ID: '115',
Name: 'Christina\nBerglund',
},
{
ID: '116',
Name: 'Hanna\nMoos',
},
{
ID: '119',
Name: 'Laurence\nLebihan',
},
{
ID: '120',
Name: 'Elizabeth\nLincoln',
Level: 'senior',
},
{
ID: '122',
Name: 'Patricio\nSimpson',
Level: 'senior',
},
{
ID: '123',
Name: 'Francisco\nChang',
},
];
const orgLinks: OrgLink[] = [
{
ID: '124',
From: '106',
To: '108',
},
{
ID: '125',
From: '106',
To: '109',
},
{
ID: '126',
From: '106',
To: '107',
},
{
ID: '127',
From: '106',
To: '110',
},
{
ID: '129',
From: '110',
To: '112',
},
{
ID: '130',
From: '110',
To: '113',
},
{
ID: '132',
From: '107',
To: '115',
},
{
ID: '133',
From: '107',
To: '116',
},
{
ID: '136',
From: '108',
To: '119',
},
{
ID: '137',
From: '108',
To: '120',
},
{
ID: '139',
From: '109',
To: '122',
},
{
ID: '140',
From: '109',
To: '123',
},
];
@Injectable()
export class Service {
getOrgItems() {
return orgItems;
}
getOrgLinks() {
return orgLinks;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>DevExtreme Demo</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx.light.css" />
<link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/26.1.5/css/dx-diagram.min.css" />
</head>
<body class="dx-viewport">
<div class="demo-container">
<demo-app>Loading...</demo-app>
</div>
<script src="https://cdn.jsdelivr.net/npm/zone.js@0.16.2/bundles/zone.umd.js"></script>
<script src="./bundle.js" type="module"></script>
</body>
</html>